DS Module 4 Graphs
DS Module 4 Graphs
GRAPHS
Graphs
DEFINITIONS
• A graph, G, consists of two sets V and E. V is a finite non-
empty set of vertices. E is a set of pairs of vertices, these pairs
are called edges.
• V(G) and E(G) will represent the sets of vertices and edges of
graph G.
• We will also write G = (V, E) to represent a graph.
• In an undirected graph the pair of vertices representing any
edge is unordered. Thus, the pairs (v1, v2) and (v2, v1)
represent the same edge.
• In a directed graph each edge is represented by a directed pair
(v1, v2). v1 is the tail and v2 the head of the edge. Therefore
<v2, v1> and <v1, v2> represent two different edges.
The graphs G1 and G2 are undirected. G3 is a
directed graph.
• V (G1) = {1,2,3,4}; E (G1) = {(1,2), (1,3), (1,4), (2,3), (2,4), (3,4)}
• V (G2) = {1,2,3,4,5,6,7}; E (G2) = {(1,2), (1,3), (2,4), (2,5), (3,6), (3,7)}
• V (G3) = {1,2,3}; E (G3) = {<1,2>, <2,1>, <2,3>}.
TERMINOLOGIES