Title: 308203A Introduction to Computing II Lecture 12: Graphs
1308-203AIntroduction to Computing IILecture
12 Graphs
Fall Session 2000
2Graphs
A way to represent relations between pairs of
objects
Definition A graph is set of vertices (V)
connected by a set of edges
(E) G (V, E) where every edge in E is a
pair of two vertices, e (v1, v2).
3Graph (example)
Let G ( a, b, c, d , (a,b) , (b,c), (c,
d), (a,d) )
a
b
c
d
4Definitions
- neighbors the nodes which are joined by an
edge - degree of node x the number of neighbors x has
a
b
c
d
5Definitions
- neighbors the nodes which are joined by an
edge - degree of node x the number of neighbors x has
degree 3
degree 1
a
b
degree 2
degree 2
c
d
6Path
A Path is a sequence of vertices (v1, v2, v3,
vi) connected by edges, i.e. For all j, 0 lt j lt
i, (vj, vj1) is in E
7Path
A Path is a sequence of vertices (v1, v2, v3,
vi) connected by edges, i.e. For all j, 0 lt j lt
i, (vj, vj1) is in E
vi
v1
8Reachability
If there exists a path from v1 to v2 then v1 is
said to be reachable from v2.
Reachability is a so-called equivalence
relation because it has the following
properties, where (x R y) denotes x reachable
from y
1. Reflexive x R x for any x 2. Symmetric x
R y ? y R x 3. Transitive x R y and y R z
? x R z
9Connected Components
This means the vertices can be partitioned into
groups of connected vertices, called connected
components
Example a graph with four connected components
10Cycles
A path which begins and ends at the same
vertex is called a cycle.
If all the vertices in the cycle are distinct,
then we say that the cycle is a simple cycle.
11Example
A simple cycle (in red)
A higher-order cycle
12Isomorphism
Equality for graphs
Two graphs, G1 and G2, are considered
isomorphic if there exists a correspondence
between the vertices of G1 and G2 such that there
is an edge between v1 and v2 in G1 if and only if
there is an edge between the corresponding
vertices v1 and v2 in G2.
13Example
Isomorphic graphs
14Example
Isomorphic graphs
15Any questions?