GRAPH
GRAPH
e1
e2
v1 v2
9. Odd or Even Vertex: If thee3 degree of vertex in the graph is
even, the vertex is said to be even vertex otherwise odd vertex.
Even vertex: B,C,D,F
Odd Vertex: A,E
10. Isolated Vertex: A vertex of graph g, which is not the
end of any edge is called isolated vertex or in other words,
isolated vertices are vertices with zero degree.
11. Pendant Vertex: A vertex of degree one is called a
pendant vertex.
12. Path: way to get from an origin to destination by
traversing edges in graph.
13. Cycle : A chain where the initial and terminal nodes
are the same and that does not use the same link more
than once is a cycle.
14. Circuit: A path in where the initial and terminal nodes
correspond. It is a cycle where all the links are traveled in
the same direction
15. Degree: The number of edges incident on a vertex is
called the degree of that particular vertex.
Types of Graph
1. Simple Graph
• A graph with no loops and no parallel edges is
called a simple graph.
2. Null Graph
A graph having no edges is called a Null Graph.
3. Directed Graph
In a directed graph, each edge has a direction.
Non-Directed Graph
A non-directed graph contains edges but
the edges are not directed ones.
4. Multiple Graph:
A graph that contains some multiple
edges(parallel edges) Is called multiple graph.
Self loops are not allowed.
5. Regular graph:
A graph G is said to be regular, if all its vertices
have the same degree. In a graph, if the degree
of each vertex is ‘k’, then the graph is called a ‘k-
regular graph’.
6. Subgraph:
A graph whose vertices and edges are subsets of another
graph. Formal Definition: A graph G'=(V', E') is a subgraph
of another graph G=(V, E)
7. Complete Graph:
• A bipartite graph ‘G’, G = (V, E) with partition V =
{V1, V2} is said to be a complete bipartite graph if
every vertex in V1 is connected to every vertex of
V2.
• In general, a complete bipartite graph connects
each vertex from set V1 to each vertex from set V2.
9. Bipartite Graph
A simple graph G = (V, E) with vertex partition V = {V1, V2}
is called a bipartite graph if every edge of E joins a vertex
in V1 to a vertex in V2.
In general, a Bipartite graph has two sets of vertices, let
us say, V1 and V2, and if an edge is drawn, it should
connect any vertex in set V1 to any vertex in set V2.
Representation of Graph
1. Adjacency Matrix
2. Adjacency List
3. Adjacency Multi-List
4. Path Matrix or Reachability Matrix
1. Adjacency Matrix
In this representation, graph can be represented using a matrix of size
total number of vertices by total number of vertices. That means if a
graph with 4 vertices can be represented using a matrix of 4X4 class. In
this matrix, rows and columns both represents vertices. This matrix is
filled with either 1 or 0. Here, 1 represents there is an edge from row
vertex to column vertex and 0 represents there is no edge from row
vertex to column vertex. undirected graph representation...
Directed graph representation...
2. Adjacency List
In this representation, every vertex of graph
contains list of its adjacent vertices. Directed
graph representation implemented using linked
list...
This representation can also be implemented
using array as follows..
Graph Traversals
General Technique for graph traversing is given below:
1. Initially al the nodes of the graph are marked as ‘unreached’.
2. After selecting a start node from where the traversing of the graph
starts, mark ‘reached’.
3. The node marked as ‘reached’ is placed on the ‘ready list’.
4. Now, the node from the ‘the ready list’ is selected and processed.
5. The processed node is deleted, and the adjacent node to the deleted
node is marked as ‘reached’ only if they are marked as ‘un-reached’.
These ‘reached’ nodes are then added to the ‘ready list’.
6. The whole process continues until the ‘ready list’ becomes empty.
Site S3
Site S1
Site S4
Site S2
• The model of www can be represented by a
graph(directed) where in nodes denote the
documents, papers, articles, etc., and the
edges represent the outgoing hyperlinks.
• Site S1 has link to page on Site S4.
• The pages S4 refers to pages on S2 and S3
2. Resource Allocation Graph
• In order to detect and avoid deadlocks, the OS
maintains Resource Allocation Graph for
processes that are active in system.
3. Coloring of Maps
Map has to be colored in such a fashion that no
two adjacent countries or regions have the same
colour.
Node represent regions and edge between two
regions denote two regions are adjacent.
4. Scene Graphs
The contents of a visual scene are also managed
by using graph data structure.
Virtual Reality Modeling Language VRML
supports scene graph programming mode.