Graphs and Digraphs
Graphs and Digraphs
GRAPHS (G)
e2 • Graphs can be used to model and analyze
e1 complex systems and relationships.
e3
• They are useful for visualizing and
understanding data.
A D
• Graphs can be used to represent a wide
range of data types, including social networks,
road networks, and the internet.
B C
GRAPHS TERMINOLOGIES Node / Vertex (V)
V(G)
Adjacent Relationship
a1
A D
• If two vertices in a graph are connected by
Edge (E)
an edge, we say the vertices are adjacent. a4 E(G)
a2
Ex : A adjacent to B and D
B a3 C
GRAPHS TERMINOLOGIES
B a3 C
GRAPHS TERMINOLOGIES
Node / Vertex (V)
V(G)
B a3 C
GRAPHS TERMINOLOGIES Node / Vertex (V)
V(G)
a5
Loop
a1
A D
Loop
Edge (E)
a4 E(G)
• In graph theory, a loop (also called a self- a2
loop or a buckle) is an edge that connects a
vertex to itself. A simple graph contains no B a3 C
loops.
Ex : a5
a5 = {A, A}
GRAPHS TERMINOLOGIES Node / Vertex (V)
V(G)
a1
A D
Edge (E)
Parallel Edges a4 E(G)
a2
a1
A D
Edge (E)
Order of a Graph a4 E(G)
a2
(Cardinality of a Graph)
B a3 C E
number of vertices in the graph.
a6
V(G) = {A, B, C, D, E}
∴ |V| = 5
GRAPHS TERMINOLOGIES Node / Vertex (V)
V(G)
F
a5
a1 a7
A D
Edge (E)
Size of a Graph a4 E(G)
a2
number of edges in the graph.
E
B a3 C
a6
∴ |E| = 7
GRAPHS TERMINOLOGIES Node / Vertex (V)
V(G)
F
a5
a1 a7
A D
Edge (E)
Degree of a vertex (δ) a4 E(G)
a2
number of edges connected to a particular
E
vertex.
B a3 C
Deg(A)
δ (A)
A (Deg) a6
a4 a4
a2 a2
E E
B a3 C B a3 C
a1
A D
a4
a2
B a3 C Complete Graph
A complete graph is a graph that
has an edge between every single
vertex in the graph
No of vertices = n
Degree of one vertex = n-1
No of Edges = n(n-1) / 2
GRAPH TYPES
A D
D
C
B
A D a4
a2
B a3 C
C
B
F
F
a5
a1 a7
Length : No of edges a7
A D
D
a4
a2
a2
B a3 C
B a3 C
6 a
Closed Walk For Digraph need to
Open Walk
C→ C consider the direction
B→F C a3 B a4 A a1 D a2 C
B a3 C a2 D a7 F Length : 4
Length : 3 C a3 B a4 A a5 A a1 D a7 F a7 D a2 C
Length : 7
Can not mention same edge
GRAPH TRAIL again and again. But vertex can
F
F
a5
a1 a7
a7
A D
D
a4
a2
a2
B a3 C
B a3 C a6
F
F
a5
a1 a7
a7
A D
D
a4
a2
a2
B a3 C
B a3 C a6
C a3 B a4 A a1 D a2 C
(Path start and end can be same)
GRAPH PATH
F
F
a5
a1 a7
a7
A D
D
G
a4 a8 a2
a2
a9
B a3 C
a3 C B
a6
Open Path Closed Path / Cycle
For Digraph need to
B→F C→ C consider the direction
B a3 C a2 D a7 F C a3 B a4 A a5 A a1 D a2 C
C a3 B a4 A a5 A a1 D a7 F a7 D a2 C
C a3 B a4 A a1 D a2 C
(Path start and end can be same)
END