Introduction To Graphs (Part-I - III)
Introduction To Graphs (Part-I - III)
Srikrishnan Divakaran
School of Engineering and Applied Sciences
Ahmedabad University
Lecture Set 11
9.1: What are Graphs? Not
• Everyday Math:
• A plot or chart of numerical data using a
coordinate system.
• Discrete mathematics:
A particular class of discrete structures (to
be defined) that is useful for representing
relations and has a convenient webby-
looking graphical representation.
05/27/20 2
What is a graph?
A set of points and lines joining these
points.
Formally:
e6
G=(V,E), V-vertices, E-edges
v1
v3
v4
V2 and v3 are
e1 adjacent. e2 is incident
e2 e3 with v2.
e5
v2
v5
e4
3
Types of Graphs:
1. Simple Graphs
Visual Representation
• A simple graph G=(V,E) of a Simple Graph
consists of:
– a set V of vertices or nodes
– a set E of edges / arcs / links: unordered pairs
of [distinct?] elements u,v V
05/27/20 4
2. Multigraphs
05/27/20 6
Directed Graphs
• Correspond to arbitrary binary relations R,
which need not be symmetric.
• A directed graph (V,E) consists of a set of
vertices V and a binary relation E on V.
• E.g.: V = people,
E={(x,y) | x loves y}
05/27/20 7
Directed Multigraphs
05/27/20 9
Graphs as models
• Networks: transportation, roadmaps, computer,
electrical, etc.
10
Graphs as models
11
Matching Problem
women men
w1 m1
w2 m2
w3 m3
w4 m4
w5 m5
12
Matching Problem
women men
w1 m1
w2 m2
w3 m3
w4 m4
w5 m5
w1 1 m1
3
1
w2 2 m2
1.5
2
w3 2 m3
1.7 4
w4 m4
3
2
w5 m5
w1 1 m1
1
1 Does there exist a
w2 2 m2 stable marriage?
1.5
2
w3 2 m3
1.7 4
w4 m4
3
2
w5 m5
• Tractable! Tm
16
Connector problem
• Design a railway network
connecting a number of
cities, with a minimum
possible construction cost.
• Or electrical network,
cable TV, gas, etc.
17
Chinese Postman Problem
• A postman begins in P.O.
18
Chinese Postman Problem
• A postman begins in P.O.
19
Chinese Postman Problem-
graph theory
• Definition: an Euler tour P.O.
Intractabl
e!
Mumbai Hyderabad
Bangalore Chennai
Madurai
22
9.2: Graph Terminology
• Adjacent, connects, endpoints, degree,
initial, terminal, in-degree, out-degree,
complete, cycles, wheels, n-cubes,
bipartite, subgraph, union.
05/27/20 23
9.2: Graph Terminology
• Adjacent, connects, endpoints, degree,
initial, terminal, in-degree, out-degree,
complete, cycles, wheels, n-cubes,
bipartite, subgraph, union.
05/27/20 24
Adjacency
Let G be an undirected graph with edge set
E. Let eE be (or map to) the pair {u,v}.
Then we say:
• u, v are adjacent / neighbors / connected.
• Edge e is incident with vertices u and v.
• Edge e connects u and v.
• Vertices u and v are endpoints of edge e.
05/27/20 25
Degree of a Vertex
• Let G be an undirected graph, vV a
vertex.
• The degree of v, deg(v), is its number of
incident edges. (Except that any self-loops
are counted twice.)
• A vertex with degree 0 is isolated.
• A vertex of degree 1 is pendant.
05/27/20 26
Handshaking Theorem
• Let G be an undirected (simple, multi-, or
pseudo-) graph with vertex set V and edge
set E. Then
deg(v) 2 E
vV
• Corollary: Any undirected graph has an
even number of vertices of odd degree.
05/27/20 27
• deg(a) = 6
• deg(b) = 4
• deg( c) = 1 pendant
• deg(d) = 0 isolated
• deg(e) = 3
• deg(f) = 4
• deg(g) = 2
• ∑deg(v) = 20 = 2∑edges=2 x 10
05/27/20 28
Directed Adjacency
• Let G be a directed (possibly multi-) graph,
and let e be an edge of G that is (or maps
to) (u,v). Then we say:
– u is adjacent to v, v is adjacent from u
– e comes from u, e goes to v.
– e connects u to v, e goes from u to v
– the initial vertex of e is u
– the terminal vertex of e is v
05/27/20 29
Directed Degree
• Let G be a directed graph, v a vertex of G.
– The in-degree of v, deg(v), is the number of
edges going to v.
– The out-degree of v, deg(v), is the number of
edges coming from v.
– The degree of v, deg(v)deg(v)+deg(v), is
the sum of v’s in-degree and out-degree.
05/27/20 30
Directed Handshaking Theorem
• Let G be a directed (possibly multi-) graph
with vertex set V and edge set E. Then:
1
vV
deg (v) deg (v) deg(v) E
vV
2 vV
• Note that the degree of a node is
unchanged by whether we consider its
edges to be directed or undirected.
05/27/20 31
• deg+(a) = 3 deg -(a) = 3
• deg+(b) = 3 deg -(b) = 1
• deg+( c) = 0 deg -(c) = 1
• deg+(d) = 0 deg -(d) = 0
• deg+(e) = 1 deg-(e) = 2
• deg+(f) = 2 deg-(f) = 2
• deg+(g) = 1 deg-(g) = 1
• ∑deg+(v) = ∑deg-(v) =1/2 ∑deg(v)= ∑edges
= 10
05/27/20 32
Special Graph Structures
Special cases of undirected graph structures:
• Complete graphs Kn
• Cycles Cn
• Wheels Wn
• n-Cubes Qn
• Bipartite graphs
• Complete bipartite graphs Km,n
05/27/20 33
Complete Graphs
• For any nN, a complete graph on n
vertices, Kn, is a simple graph with n
nodes in which every node is adjacent to
every other node: u,vV: uv{u,v}E.
K1 K2 K3 K4
K5 K6
n `
n(n 1)
Note that Kn has i edges.
i 1 2
05/27/20 34
Cycles
• For any n3, a cycle on n vertices, Cn, is a
simple graph where V={v1,v2,… ,vn} and
E={{v1,v2},{v2,v3},…,{vn1,vn},{vn,v1}}.
C3 C4 C5 C6
C7 C8
W3 W4 W5 W6
W7 W8
Q0
Q1 Q2 Q4
Q3
05/27/20 37
Bi-partite Graphs
Complete Bi-partite Graphs
Subgraphs
• A subgraph of a graph G=(V,E) is a graph
H=(W,F) where WV and FE.
05/27/20 40
Induced Sub-graphs
05/27/20 41
9.3: Graph Representations
• Graph representations:
– Adjacency lists.
– Adjacency matrices.
– Incidence matrices.
05/27/20 42
Adjacency Lists
• A table with 1 row per vertex, listing its
adjacent vertices.
Adjacent
a b Vertex Vertices
a b, c
c d
e b a, c, e, f
f c a, b, f
d
e b
f c, b
05/27/20 43
Directed Adjacency Lists
• 1 row per node, listing the terminal nodes
of each edge incident from that node.
05/27/20 44
Adjacency Matrices
• Matrix A=[aij], where aij is 1 if {vi, vj} is an
edge of G, 0 otherwise.
a b a b c d e
c
a 0 1 1 0 0
e
d b 1 0 1 0 1
c 1 1 0 0 0
d 0 0 0 0 0
e
0 1 0 0 0
05/27/20 45
Isomorphic Graphs
Are these graphs isomorphic ?
Paths in Undirected Graphs
05/27/20 48
Paths in Directed Graphs
05/27/20 49
Connectedness in Undirected Graphs
05/27/20 50
Cut Vertices in Graphs
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). Graphs without any cut vertices are called non-separable graphs.
Vertex Connectivity in Undirected
Graphs
Vertex connectivity is the minimum number of vertices that you need to remove to
disconnect a graph. Edge connectivity is the minimum number of edges you need to
remove to disconnect a graph.
Edge Connectivity in Graphs
Sometimes the removal from a graph a set of edges disconnects the graph (creates two or
more components), such edges are called called cut edges.
Edge Connectivity in Undirected
Graphs
Edge connectivity is the minimum number of edges that you need to remove to disconnect
a graph. Edge connectivity is the minimum number of edges you need to remove to
disconnect a graph.
Relationship between edge and vertex
connectivity
05/27/20 56
Graph Isomorphism – Revisited
05/27/20 57
Graph isomorphism Revisited
Euler Circuit
Euler Circuits and Paths
Hamilton Paths and Circuits
Hamilton Paths and Circuits
Graph Traversals
and so on…
Finding Strongly Connected
Components
• Strongly connected:
– A directed graph is strongly connected if and only if, for each pair of
vertices v and w, there is a path from v to w.