Graph Theory-2
Graph Theory-2
1. A node or a vertex.
1. Social Network: Each user is represented as a node and all their activities, suggestion
and friend list are represented as an edge between the nodes.
2. Google Maps: Various locations are represented as vertices or nodes and the roads
are represented as edges and graph theory is used to find shortest path between two
nodes.
Types of Graph
1. Undirected Graphs:
An undirected graph is a graph where the edges do not have a specific direction and
it is bidirectional in nature.
2. Directed Graphs:
A directed graph is a graph that is unidirectional, in this the edges have a specific
direction.
3. Null Graph:
A graph of order n and size zero is a graph where there are only isolated vertices with no
edges connecting any pair of vertices. A null graph is a graph with no edges. In other
words, it is a graph with only vertices and no connections between them.
4. Trivial Graph:
A graph is said to be trivial if a finite graph contains only one vertex and no edge. A
trivial graph is a graph with only one vertex and no edges. It is also known as a singleton
graph or a single vertex graph. A trivial graph is the simplest type of graph and is often
used as a starting point for building more complex graphs.
5. Simple Graph:
A simple graph is a graph that does not contain more than one edge between the pair of
vertices. A simple railway track connecting different cities is an example of a simple
graph.
6. Finite Graphs:
A graph is said to be finite if it has a finite number of vertices and a finite number of
edges. A finite graph is a graph with a finite number of vertices and edges. In other words,
both the number of vertices and the number of edges in a finite graph are limited and can
be counted.
7. Infinite Graph:
8. Multi Graph:
Any graph which contains some parallel edges but doesn’t contain any self-loop is called
a multigraph. For example a Road Map.
Parallel Edges: If two vertices are connected with more than one edge then such
edges are called parallel edges that are many routes but one destination.
Loop: An edge of a graph that starts from a vertex and ends at the same vertex is
called a loop or a self-loop.
9. Complete Graph:
A simple graph with n vertices is called a complete graph if the degree of each vertex is
n-1, that is, one vertex is attached with n-1 edges or the rest of the vertices in the graph. A
complete graph is also called Full Graph.
A simple graph is said to be regular if all vertices of graph G are of equal degree. All
complete graphs are regular but vice versa is not possible. A regular graph is a type of
undirected graph where every vertex has the same number of edges or neighbours.
12. Bipartite Graph:
A graph G = (V, E) is said to be a bipartite graph if its vertex set V(G) can be partitioned into
two non-empty disjoint subsets. V1(G) and V2(G) in such a way that each edge e of E(G) has
one end in V1(G) and another end in V2(G). The partition V1 U V2 = V is called Bipartite of
G. Here in the figure: V1(G)={V5, V4, V3} and V2(G)={V1, V2}
If the vertices and edges of a graph are labeled with name, date, or weight then it is called a
labeled graph. It is also called Weighted Graph.
14. Connected or Disconnected Graph:
Graph G is said to be connected if any pair of vertices (Vi, Vj) of a graph G is reachable from
one another. Or a graph is said to be connected if there exists at least one path between each
and every pair of vertices in graph G, otherwise, it is disconnected.
A cyclic graph is defined as a graph that contains at least one cycle which is a path that
begins and ends at the same node, without passing through any other node twice.
A planar graph is a graph that we can draw in a plane in such a way that no two edges
intersect each other except at a vertex to which they meet.
A graph that cannot be drawn without at least one pair of its crossing edges is known as a
non-planar graph.
A vertex with degree one (i.e., deg(V)=1) is called a pendant vertex. Whereas a vertex with
degree zero (i.e., deg(V)=0 is called an isolated vertex.
Undirected Graph
Directed Graph
In an undirected graph degree of vertex ‘v’ is denoted as deg(v). It is equal to no. of edges
incident with the vertex.
Example 1
In degree, and
Out degree.
In degree of a Graph
In degree of vertex V is the number of edges which are coming into the vertex V.
Notation : deg−(V).
Out degree of vertex V is the number of edges which are going out from the vertex V.
Notation : deg+(V).
Hence, in a directed graph, the degree of a vertex is equal to the sum of the in-degree and out-
degree of a vertex, i.e., deg(V)= deg−(V)+ deg+(V).
Handshaking Theorem
In Graph Theory, Handshaking Theorem states in any given graph, Sum of degree of all the
vertices is twice the number of edges contained in it.
∑ ( )
Questions:
A simple graph G has 24 edges and degree of each vertex is 4. Find the number of vertices.
Solution-
Given-
Number of edges = 24
Degree of each vertex = 4
n x 4 = 2 x 24
NOTE: In any graph,
Subgraph:
A subgraph G of a graph G’ whose vertex set and edge set subsets of the graph G. In simple
words a graph is said to be a subgraph if it is a part of another graph.
A subgraph with no common vertex is called a vertex disjoint subgraph of the parent graph
G. Since the vertices in a vertex disjoint graph cannot have a common edge, a vertex disjoint
subgraph will always be an edge-disjoint subgraph.
Definition: If G1(v1, e1) and G2(v2, e2) are said to be isomorphic if there exists one to one
corresponding between their vertices and edges.
- both graphs are connected or both graphs are not connected, and
- pairs of connected vertices must have the corresponding pair of vertices connected.
Firstly, label the graphs. It “looks” true, so check all the things we know:
Number of loops: 0.
Homemorphic Graph
Two graph G1 and G2 are said to be homeomorphic graphs, if one can be obtained from
other by introduction of new vertices on existing edges.
Example:
G1 G2
Graph Representation:
1. Set Representation: Set representation of a graph involves two sets: Set of vertices V
= {V1, V2, V3, V4} and set of edges E = {{V1, V2}, {V2, V3}, {V3, V4}, {V4, V1}}. This
representation is efficient for memory but does not allow parallel edges.
o Path Matrix: This matrix includes information about the simple path between
two vertices. Here, Pij = 1 if there is a path from Vi to Vj otherwise 0. It is also
called as reachability matrix of graph G.
Adjacency Matrix
Example:
vertex v0 v1 v2 v3 v4
v0 0 1 1 1 0
v1 1 0 0 1 1
v2 1 0 0 1 0
v3 1 1 1 0 1
v4 0 1 0 1 0
vertex v0 v1 v2 v3 v4
v0 0 1 1 1 0
v1 0 0 0 1 1
v2 0 0 0 1 0
v3 0 0 0 0 1
v4 0 0 0 0 0
Example:
Example:
Path and Circuit
1. Walk –
Open walk- A walk is said to be an open walk if the starting and ending vertices are different
i.e. the origin vertex and terminal vertex are different.
Closed walk- A walk is said to be a closed walk if the starting and ending vertices are
identical i.e. if a walk starts and ends at the same vertex, then it is said to be a closed walk.
2. Trail –
Trail is an open walk in which no edge is repeated.
2. Circuit –
Traversing a graph such that not an edge is repeated but vertex can be repeated and it is
closed also i.e. it is a closed trail.
3. Path –
It is a trail in which neither vertices nor edges are repeated i.e. if we traverse a graph such
that we do not repeat a vertex and nor we repeat an edge.
5. Cycle –
Traversing a graph such that we do not repeat a vertex nor we repeat a edge but the starting
and ending vertex must be same i.e. we can repeat starting and ending vertex only then we
get a cycle.
Eulerian path is a path in a graph that visits every edge exactly once. Eulerian Circuit is an
Eulerian Path that starts and ends on the same vertex.
To detect the path and circuit, we have to follow these conditions −
Hamiltonian Path – A Hamiltonian path in a graph is a path that visits every vertex
exactly once. In other words, it is a sequence of vertices in a graph such that no vertex
is visited more than once.
Hamiltonian Circuit – A Hamiltonian circuit (or cycle) in a graph is a closed path that
visits every vertex exactly once, except for the starting vertex which is also the ending
vertex.
Graph b. has no Hamilton circuits, though it has a Hamilton path (one example is
ABCDEJGIFH)