Graphs and Trees: Basic Terminology
Graphs and Trees: Basic Terminology
Basic Terminology
Graph
• A graph G = (V ,E) consists of V , a nonempty set
of vertices (or nodes) and E, a set of edges. Each
edge has either one or two vertices associated
with it, called its endpoints.
• An edge is said to connect its endpoints.
• A graph with an infinite vertex set or an infinite
number of edges is called an infinite graph,
• a graph with a finite vertex set and a finite edge
set is called a finite graph
Types of Graphs
• Directed Graph (Diagraph)
• Undirected Graph
• Weighted Graphs
Undirected Graph
• Null graph
• Simple Graph
• Complete Graph
• Cyclic Graph
• Bipartite Graph
Null Graph-
A graph which contains only isolated node is called a null graph
i.e. set of edges in a null graph is empty.
Null graph is denoted on 'n' vertices by Nn.
Simple graph
• A graph which has neither loops nor multiple
edges i.e. where each edge connects two
distinct vertices and no two edges connects
the same pair of vertices is called a simple
graph.
Multigraph & Psuedograph
• Any graph which contains some multiple edges is called
a multigraph. In a multigraph, no loops are allowed.
• A graph in which loops and multiple edges are allowed is
called psuedograph.
Complete Graph
• A simple graph G is said to be complete if every vertex in G is
connected with every other vertex i.e. if G contains exactly
one edge between each pair of distinct vertices. Complete
graph is denoted on 'n' vertices bt Kn. Kn has exactly n(n-1) /2
edges.
Regular Graph
• A graph in which all the vertices are of equal degree is called
a regular graph. If the degree of each vertex is r, then the
graph is called a regular graph of degree r.
• Every null graph is a regular graph of degree zero and a
complete graph Kn is a regular graph of degree n-1.
Cyclic Graph-
• A graph with continuous sequence of vertices and edges is
called a cyclic graph.
• Cyclic graph is denoted on 'n' vertices bt Cn where n >=3
Wheel Graph
• A graph formed by adding a vertex inside a cycle and connecting it to every other vertex is known as wheel
graph.
• A graph where a set of vertices of a graph can be partitioned into two subesets
in such a way that no pair of vertices in the same set are adjacent to each other
• -> This theorem applies even if multiple edges and loops are
present. The theorem holds this rule that if several people
shake hands, the total number of hands shake must be even
that is why the theorem is called handshaking theorem.
Some Representations for Graph
• Adjacency Matrices
• Incidence matrices
– Represent the incidence matrix for given graph.
Incidence Matrix
Isomorphism of Graph
• The simple graphs G1 = (V1,E1) and G2 = (V2,E2) are
isomorphic if there exists a oneto-one and onto
function f from V1 to V2 with the property that a and b
are adjacent in G1 if and only if f (a) and f (b) are
adjacent inG2, for all a and b in V1. Such a function f is
called an isomorphism.Two simple graphs that are not
isomorphic are called nonisomorphic.
Show that the graphs G = (V ,E) and H = (W, F),
displayed in Figure 8, are isomorphic.
The function f with f (u1) = v1, f (u2) = v4, f (u3) = v3, and f (u4) = v2 is a
oneto- one correspondence between V and W. To see that this
correspondence preserves adjacency,
• note that adjacent vertices in G are u1 and u2, u1 and u3, u2 and u4, and
u3 and u4, and each of the
• pairs f (u1) = v1 and f (u2) = v4, f (u1) = v1 and f (u3) = v3, f (u2) = v4 and f
(u4) = v2, and f (u3) = v3 and f (u4) = v2 consists of two adjacent vertices
in H.
Determine wheather the graphs are
isomorphic or not
1. Not Isomorphic
2.
Isomorphic
• Both G and H have six vertices and seven edges. Both have four
vertices of degree two and two vertices of degree three.
• arbitrarily set f (u1) = v6. [If we found that this choice did not lead to
isomorphism, we would then try f (u1) = v4.]. We arbitrarily set f (u2)
= v3. Continuing in this way, we set f (u3) = v4, f (u4) = v5, f (u5) = v1,
and f (u6) = v2.We now have a one-to-one correspondence between
the vertex set of G and the vertex set of H, namely, f (u1) = v6, f (u2) =
v3, f (u3) = v4, f (u4) = v5, f (u5) = v1, f (u6) = v2.
• cut vertices (or articulation points): Sometimes the removal
from a graph of a vertex and all incident edges produces a
subgraph with more connected components. Such vertices
are called cut vertices (or articulation points).
• The removal of a cut vertex from a connected graph produces
a subgraph that is not connected.
• cut edge or bridge: an edge whose removal produces a graph
with more connected components than in the original graph is
called a cut edge or bridge.
• Ex. in a graph representing a computer network, a cut vertex
and a cut edge represent an essential router and an essential
link that cannot fail for all computers to be able to
communicate.
• Find the cut vertices and cut edges in the graph G1 shown in
Figure
4 1 3 10
2 2 ∞
∞ C D E
5 8 ∞ 4 6
1
F G
∞ ∞
38
Example: Update neighbors' distance
0 2
2
A B
4 1 3 10
2 2 ∞
∞ C D E
5 8 1 4 6
Distance(B) = 2 1
F G
Distance(D) = 1
∞ ∞
39
Example: Remove vertex with minimum
distance
0 2
2
A B
4 1 3 10
2 2 ∞
∞ C D E
5 8 1 4 6
1
F G
∞ ∞
40
Example: Update neighbors
0 2
2
A B
4 1 3 10
2 2
3 C D E 3
5 8 1 4 6
Distance(C) = 1 + 2 = 3 1
F G
Distance(E) = 1 + 2 = 3
Distance(F) = 1 + 8 = 9 9 5
Distance(G) = 1 + 4 = 5
41
Example: Continued...
Pick vertex in List with minimum distance (B) and update neighbors
0 2
2
A B
4 1 3 10
2 2
3 C D E 3
5 8 1 4 6
Note : distance(D) not
1
F G updated since D is already
known and distance(E) not
9 5 updated since it is larger
than previously computed
42
Example: Continued...
Pick vertex List with minimum distance (E) and update neighbors
0 2
2
A B
4 1 3 10
2 2
3 C D E 3
5 8 1 4 6
1
F G
No updating
9 5
43
Example: Continued...
Pick vertex List with minimum distance (C) and update neighbors
0 2
2
A B
4 1 3 10
2 2
3 C D E 3
5 8 1 4 6
Distance(F) = 3 + 5 = 8 1
F G
8 5
44
Example: Continued...
Pick vertex List with minimum distance (G) and update neighbors
0 2
2
A B
4 1 3 10
2 2
3 C D E 3
5 8 1 4 6
1
F G
Previous distance
6 5
Distance(F) = min (8, 5+1) = 6
45
Example (end)
0 2
2
A B
4 1 3 10
2 2
3 C D E 3
5 8 1 4 6
1
F G
6 5
Pick vertex not in S with lowest cost (F) and update neighbors
46
Another Example
Another Example
Another Example
Another Example
Another Example
Another Example
Another Example
Another Example
Another Example
Traveling Salesperson Problem
• A traveling salesperson wants to visit each of n
cities exactly once and return to his starting
point.
• The following table shows the three different Hamilton
circuits and their weights:
• Thus we see that the circuit a-c-b-d-a (or the same circuit
starting at some other point but traversing the vertices in the
same or exactly opposite order) is the one with minimum
total weight.
Planar Graph
• A graph is called planar if it can be drawn in the plane without
any edges crossing, Such a drawing is called a planar
representation of the graph.
Is this a planar graph
• note that there is no way to place the final vertex v6 without forcing
a crossing.
• Application of Planarity of graphs plays an important role in the
design of electronic circuits
Euler’s Theorem
• Let G be a connected planar simple graph with
e edges and v vertices. Let r be the number of
regions in a planar representation of G.
Then r = e − v + 2.
– Proof:
• The relationship r1 = e1 − v1 + 2 is true for G1, because e1 = 1, v1 =
2, and r1 = 1
• What is the chromatic number of the complete bipartite graph Km,n, where
m and n are positive integers?
• χ(Km,n) = 2. This means that we can color the set of m vertices with one color
and the set of n vertices with a second color.
• Because edges connect only a vertex from the set of m vertices and a vertex
from the set of n vertices, no two adjacent vertices have the same color. A
coloring of K3,4 with two colors
• What is the chromatic number of the graph Cn, where n ≥ 3?