You are on page 1of 14

Introduction to Graph Theory

Content
1. Definitions
2. Types of Graphs
3. Sub Graphs
4. Connected Graph
5. DFS
6. BFS
7. Trees
8. Rooted Trees
9. Binary Tree
10. Binary Search Tree
11. Hamiltonian Graphs
Definitions
 What is Graph Theory ?
The study of points and lines is
known as graph theory. It is a branch of mathematics
that focuses on the investigation of graphs. The
mathematical truth is shown visually in this picture.
The study of how edges (lines) and vertices (nodes)
interact is known as "graph theory.“
Types of Graphs
1. Null Graphs
2. Trivial Graphs
3. Simple Graphs
4. Undirected Graphs
5. Directed Graphs
6. Complete Graphs
7. Connected Graphs
8. Disconnected Graphs
9. Regular Graphs
10. Cyclic Graphs
11. Acyclic Graphs
Sub Graphs

Definition: A Subgraph S of a graph G is a graph whose vertex set V(S) is a subset of the
vertex set V(G), that is V(S)⊆V(G), and whose edge set E(S) is a subset of the edge set
E(G), that is E(S)⊆E(G).
Connected Graphs
 A linked graph is one in which we can go from any one vertex to any other
vertex.
 Every pair of vertices in a linked graph has at least one path connecting
them.
DFS (Depth First Search)

Depth First Traversal (or DFS) for a graph is similar


to Depth First Traversal of a tree. The only catch here
is, that, unlike trees, graphs may contain cycles (a node
may be visited twice). To avoid processing a node more
than once, use a Boolean visited array. A graph can
have more than one DFS traversal.
How does DFS work ?
BFS(Breadth First Search)

The Breadth First Search (BFS) algorithm is


used to search a graph data structure for a node that
meets a set of criteria. It starts at the root of the
graph and visits all nodes at the current depth level
before moving on to the nodes at the next depth
level.
Trees
A tree is a mathematical structure that can be viewed as
either a graph or as a data structure. The two views are
equivalent, since a tree data structure contains not only a set
of elements, but also connections between elements, giving
a tree graph.
Rooted Trees
A rooted tree is a tree in which a special ("labeled") node is singled
out. This node is called the "root" or (less commonly) "eve" of the
tree. Rooted trees are equivalent to oriented trees (Knuth 1997,
pp. 385-399). A tree which is not rooted is sometimes called a
free tree, although the unqualified term "tree" generally refers to a
free tree.
Binary Trees
A binary tree is a tree-type non-linear data structure with a maximum
of two children for each parent. Every node in a binary tree has a left
and right reference along with the data element. The node at the top
of the hierarchy of a tree is called the root node.
Binary Search Tree

Binary Search Tree is a node-based binary tree data


structure which has the following properties:
 The left subtree of a node contains only nodes with keys
lesser than the node’s key.
 The right subtree of a node contains only nodes with
keys greater than the node’s key.
 The left and right subtree each must also be a binary
search tree.
Hamiltonian Graph

 A Hamiltonian graph is a connected graph that contains


a Hamiltonian cycle/circuit. Hamiltonian cycle:
Hamiltonian cycle is a path that visits each and every
vertex exactly once and goes back to starting vertex.

You might also like