Professional Documents
Culture Documents
9/14/2023
10. Graphs
Graphs and Graph Models
deg( v) 2 E
v V
v V 2 v V
K1 K2 K3 K4
K5 K6
K2,3 K3,5
• Graph representations:
– Adjacency Lists.
– Adjacency Matrices.
– Incidence Matrices.
a b Adjacent
Vertex
Vertices
c d a b, c
e
f b a, c, e, f
c a, b, f
d -
e b
f c, b
a b a b c d e
a 0 1 1 0 0
b 1
c e
d 1 0 1 0
c 1 1 0 0 0
d 0 0 0 0 0
e
0 1 0 0 0
1 1 1 0 a b
1 0 0 1
A
1 0 0 1
0 1 1 0 d c
V3 V5
V4
V5 V2
a e2 b
Let G = {V, E}, e3 e4
e5
where V= {a, b, c, d} and
E = {e1, e2, e3, e4, e5}. d
e1 c
• Simple path: a, d, c, f, e
The edges are {a, d }, {d, c}, {c, f }, {f, e}
Length = 4
• Circuit: b, c, f, e, b
The edges are {b, c},{c, f }, {f, e},{e, b}
Length = 4
• Not a path: d, e, c, a because {e, c} is not an edge
• Not a simple path: a, b, e, d, a, b because {a, b} appears
twice, Length = 5
Arab Open University – Faculty of Computer Studies 39
MT131 - Discrete Mathematics
Paths in Directed Graphs
b d
• Definition 1:
A directed graph is strongly connected if there is
a path from a to b and from b to a whenever a and
b are vertices in the graph.
• Definition 2:
A directed graph is weakly connected if there is a
path between every two vertices when the
direction of edges are disregarded.
a b a b
c d c d
• Properties:
o There is a unique simple path between any 2
of its vertices.
o No loops.
o No multiple edges.
●a
●b
c● ●d
e● ●f
a b
d
c
e
f
b
c d
f g
e
y
• Root: Vertex with in-degree 0
[Node a is the root]
b c
a
Left subtree of g Right subtree of g
b g
h j
c e h j
m
k n
d f k n m
10 20 50 60
15 40
32