2. What is graph
Graphs consist of
points called vertices
lines called edges
1. Edges connect two vertices.
2. Edges only intersect at vertices.
3. Edges joining a vertex to itself are
called loops.
3. Example
FlexoFlexo BenderBender LeelaLeela
FryFry AmyAmy
This is also a graph. The vertices just happen to have
people’s names.
Such a graph could represent friendships (or any kind of
relationship).
FarnsworthFarnsworth
ZoidbergZoidberg
4. Theory of Large Graphs
Large graphs
Billion vertices
Exact edges present not critical
Theoretical basis for study of large graphs
Maybe theory of graph generation
Invariant to small changes in definition
Must be able to prove basic theorems
5. Type of graph
Weighted Graph
Undirected Graph
Directed Graph
Connected Graphs
Complete Graphs
6. TRAVERSING A GRAPH
1.DFS:
DFS means death first search, we use
here STACK
2.BFS:
BFS means breath first search, we use
here QUEUE
7. DFS
Print :C STACK:E,F,D
Print:D STACK:E,F
Print:F STACK:E,I
Print:I STACK:E,H
Print:H STACK:E,G
Print:E STACK:B
Print:B STACK;
C,D,F,I,H,G,E
A
B C D
E
F G
I H
9. BFS
FRONT=1 QUEUE=A
REAR=1 ORIG= NULL
FRONT=2 QUEUE=A,B,C,D
REAR=4 ORIG=NULL, A,A,A
FRONT=3 QUEUE=A,B,C,D
REAR=4 ORIG=NULL,A,A,A,C
…………
FRONT=5 QUEUE=A,B,C,D,E,F,I
REAR=7 QUEUE=NULL,A,A,A,C,C,E
NOW USING BACK TRACK:
I –E –C-A
A
B C D
E
F G
I H
10. Some applications of Graph
Theory
Models for communications and electrical
networks
Models for computer architectures
Network optimization models for
operations analysis, including scheduling
and job assignment
Analysis of Finite State Machines
Parsing and code optimization in
compilers