SlideShare a Scribd company logo
Company
LOGO
Presentation Topic
What is a Graph?
 A data structure that consists of a set of nodes
(vertices) and a set of edges that relate the nodes to
each other
 The set of edges describes relationships among the
vertices
A graph G consists of two things:
1.A set V of elements called nodes(or points or vertices)
2.A set E of edges such that each edge e in E is identified with a unique pair
[u,v] of nodes in V, denoted by e=[u,v]
Suppose e=[u,v]. Then the nodes u and v are called endpoints of e and u and v
are said to be adjacent nodes or neighbors.
Node or
Point or
vertex
Edge
u
v
e=[u,v]
Adjacentnodesorneighbors
Degree of a graph
The degree of a node u, written as deg(u), is the
number of edges containing u.
If deg(u)=0 that is, if u does not belong to any
edge then u is called an isolated node.
A
B C
D
E
Nodes degree
A 4
B 3
C 2
D 3
E 4
F 0F
Isolated node
Directed Graph
 Each edge is assigned a direction or each edge E is
identified with ordered pair (u,v)
 (u,v) directed graph
 [u,v] undirected graph
 U=origin
 v=destination
Connected Graph
A graph G is said to be connected graph if
there is atleast one path between every pair
of vertices in G.
A graph which is not connected is called
disconnected graph.
Strongly Connected Graph
A directed graph G is said to be
strongly connected if foreach pairu,v
of nodes in G there is a path fromu to
v and there is also a path fromv to u.
Strongly Connected Components
A strongly connected component of a directed graph G is a 
subgraph that is strongly connected, and 
is maximal with this property: 
no additional edges or vertices from G can be included in the 
subgraph without breaking its property of being strongly 
connected.
 The collection of strongly connected components forms 
a partition of the set of vertices of G.
In simple words,
 A strongly connected component (SCC) of a
directed graph is a maximal strongly connected subgraph.
Depth-First-Search
(DFS)
 The idea behind DFS is travel as far as
you can down a path
 DFS can be implemented efficiently using
a stack .
 This algorithm is similar to inorder
traversal of a binary tree i.e. first of all we
process the left node then root and then
the right node.
J
print
J
D
K
K
E
G
G
C
C
F
F E D
Kosaraju's algorithm
 Kosaraju's algorithm (also known as
the Kosaraju–Shariralgorithm) is a linear
time algorithm to find the strongly
connected components  of a directed
graph.
 It makes use of the fact that
the transpose graph (the same graph with
the direction of every edge reversed) has
Algorithm
1) Let G be a directed graph and S be an empty stack.
2) Perform a depth-first search starting from any v. 
3) Reverse the directions of all arcs to obtain the transpose
graph.
4) Again perform depth-first search on transpose graph.
A B
C
D E
A B
C
D
E
A group of people are generally strongly connected (For example,
students of a class or any other common place). Many people in
these groups generally like some common pages or play common
games. The SCC algorithms can be used to find such groups and
suggest the commonly liked pages or games to the people in the
group who have not yet liked commonly liked a page or played a
game.
Use of SCC algorithm in Social life
MultigraphMultigraph
 A graph G is said to be a multigraph if itA graph G is said to be a multigraph if it
has:has:
1.1. multiple edgesmultiple edges
2.2. LoopsLoops
A
B C
D
e1
e7 e6
e5
e4
e3
e2
Directed Graph
 A directed graph G also called a digraph
or graph is the same as multigraph
except that each edge in G is assigned a
direction.
Outdegree= number of outgoing edges
Indegree= number of incoming edges
U- origin
V - destination
A
B
C
D
E
Nodes Indegree outdegree
A 0 4
B 1 1
C 2 1
D 3 0
E 1 1
Directed Graph
Connected Graph
A graph G is said to be connected graph if
there is atleast one path between every pair
of vertices in G.
A graph which is not connected is called
disconnected graph.
Articulation PointArticulation Point
 An articulation point in a connected graph
is a vertex that, if delete would break the
graph into two or more pieces (connected
components).
A
B
F
D
E
C
G
L
J
H I
K
M
Articulation points:- A,H,G
Biconnected GraphBiconnected Graph
 A graph with no articulation point is called
biconnected graph.
 In other words, a graph is biconnected if
and only if any vertex is deleted, the graph
remains connected.
A
B C
D
Biconnected Components
 A biconnected component of a graph is a
maximal biconnected subgraph.
 A biconnected subgraph that is not
properly contained in a larger biconnected
subgraph.
A
B
C
D
F
E
G
H I
J K
L M
A
B
C
D
F
E
G
A
B
C
F
E
G
If we delete D
A
B
C
D
F
G
If we delete E
 Let G be a directed graph with m nodes
v1,v2…….,vm. Suppose we want to find
the path matrix P of the graph G.
Warshall gave an alogrithm for this
purpose that is much more efficient than
calculating the powers of the adjacency
matrix A
Warshall’s Algorithm: Shortest Paths
Where adjacency matrix A =(aij) of the graph G is m x m
matrix defined as follows:
aij= 1 If vi is adjacent to vj, i.e. if there is an edge (vi,vj)
0 otherwise
such a matrix A, which contains entries of only 0 and 1, is called a
bit matrix or a boolean matrix
 This algorithm is used to find the shortest
paths in G when G is weighted.
 First we define m-square boolean matrices
P0,P1…….,Pm as follows:
 Let Pk[i,j] denote the i, j entry of the
matrix Pk.
 Then we define
 Pk[i,j]=
1 ,if there is a simple path from vi to vj which does
not use any other node except possibly v1,v2,
…..,vk
0 ,otherwise
In other words,
P0[i,j]=1, if there is an edge from vi to vj
P1[i,j]=1, if there is a simple path from vi to vj which does not use any other node
except possibly v1.
P2[i,j]=1, if there is a simple path from vi to vj which does not use any other node
except possibly v1 and v2.
 Observe that P0=A, the adjacency matrix of G.
 Since G has only m nodes, the last matrix
Pm=P, the path matrix of G.
 Warshall observed that Pk[i,j]=1 can occur only
if one of the following two cases occur:
1. There is a simple path from vi to vj which does
not use any other node except possibly v1,v2,
….,vk-1, hence
Pk-1[i,j]=1
vi ……….. vj
2. There is a simple path from vi to vk and
a simple path from vk to vj where each
path does not use any other nodes
except possibly v1,v2,……,vk-1; hence
Pk-1[i,k]=1 and Pk-1[k,j]=1
vi ……….. ………..vk vj
 Accordingly, the elements of matrix Pk can
be obtained by:
Pk[i,j]=Pk-1[i,j] v (Pk-1[i,k] Pk-1[k,j])
Where V and denote the logical OR and AND operator
^ 0 1
0 0 0
1 0 1
v 0 1
0 0 1
1 1 1
A B
CD
0 0 0 0
1 0 1 0
0 0 0 1
1 0 0 0
P0 =
 P1[1,1]=P0[1,1]v(P0[1,1]^P0[1,1])
=0v(0^0)
=0v0=0
 P1[1,2]=P0[1,2]v(P0[1,1]^P0[1,2])
=0v(0^0)
=0v0=0
 P1[1,3]=P0[1,3]v(P0[1,1]^P0[1,3])
=0v(0^0)
=0v0=0
 P1[1,4]=P0[1,4]v(P0[1,1]^P0[1,4])
=0v(0^0)
=0v0=0
P1[2,1]=P0[2,1]v(P0[2,1]^P0[1,1])
=1v(1^0)
=1v0=1
P1[2,2]=P0[2,2]v(P0[2,1]^P0[1,2])
=0v(1^0)
=0v0=0
P1[2,3]=P0[2,3]v(P0[2,1]^P0[1,3])
=1v(1^0)
=1v0=1
P1[2,4]=P0[2,4]v(P0[2,1]^P0[1,4])
=0v(1^0)
=0v0=0
P1 =
0 0 0 0
1 0 1 0
- - - -
- - - -
Shortest path algorithm
 Let G be a directed graph with m nodes
v1,v2,…..vm.
 Suppose G is weighted i.e. suppose each
edge e in G is assigned a non negative
number w(e) called the weight or length of
the edge e.
Then G is maintained in memory by its
weight matrix W=(wij) defined as:
Wij= W(e), if there is an edge e from vi to vj
0, if there is no edge from vi to vj
 Path matrix P tells us whether or not there are paths
between the nodes.
 Now we want to find a matrix Q which tell us the lengths of
the shortest paths between the nodes or a matrix Q=(qij)
where
qij= length of shortest path from vi to vj.
 Here we define a sequence of matrices Q1,Q2,…..Qm
defined as
Qk[i,j]= the smaller of the length of the preceding paths from
vi to vj or the sum of the lengths of preceeding paths from vi
to vk and from vk to vj.
Qk[i,j]=min(Qk-1[i,j],Qk-1[i,k]+Qk-1[k,j])
R U
S T
W =
R S T U
R
S
T
U
4
1275
3
7 5 0 0
7
7 0 0 2
0 3 0 0
4 0 1 0
R S T U
R
S
T
U
7 5 0 0
7 0 0 2
0 3 0 0
4 0 1 0
W =Q0 =
Q1(1,1) =MIN(Q0(1,1),Q0(1,1)+Q0(1,1))
=MIN(7,7+7)
=MIN(7,14)= 7
Q1(1,2) =MIN(Q0(1,2),Q0(1,1)+Q0(1,2))
=MIN(5,7+5)
=MIN(5,12)= 5
Q1(2,1) =MIN(Q0(2,1),Q0(2,1)+Q0(1,1))
=MIN(7,7+7)
=MIN(7,14)= 7
Q1(3,1) =MIN(Q0(3,1),Q0(3,1)+Q0(1,1))
=MIN( , +7)
=MIN( ,14 )= 7
R S T U
R
S
T
U
7 5 0 0
7 0 0 2
0 3 0 0
4 0 1 0
W =Q0 =Q1 = 12
Q2(1,1) =MIN(Q1(1,1),Q1(1,1)+Q1(1,1))
=MIN(7,5+7)
=MIN(7,12)= 7
Q1(1,3) =MIN(Q1(1,3),Q1(1,2)+Q1(2,3))
=MIN( , 5+ )
=MIN( ,14 )= 7
Similarly, proceeding like this we get a new matrix....
R S T U
R
S
T
U
7 5 0 0
7 0 0 2
0 3 0 0
4 0 1 0
W =Q0 =Q1 = 12Q2 =
10
7
5
11
Q3(1,1) =MIN(Q2(1,1),Q2(1,3)+Q2(3,1))
=MIN(7, +10)
=MIN(7, )= 7
Q3(2,1) =MIN(Q2(2,1),Q2(2,3)+Q2(3,1))
=MIN(7, +5)
=MIN(7, ) = 7
Q3(3,1) =MIN(Q2(3,1),Q2(3,3)+Q2(1,3))
=MIN(10, +7 )
=MIN(10,14 )= 10
Similarly, proceeding like this we get a new matrix....
R S T U
R
S
T
U
7 5 0 0
7 0 0 2
0 3 0 0
4 0 1 0
W = 12Q2 =
10
7
5
11
Q3 =
4 6
Q4(1,1) =MIN(Q3(1,1),Q3(1,4)+Q3(4,1))
=MIN(7,7+4)
=MIN(7,11)= 7
Q4(2,1) =MIN(Q3(2,1),Q3(2,4)+Q3(4,1))
=MIN(7,2+4)
=MIN(7,6)= 6
Q4(3,1) =MIN(Q3(3,1),Q3(2,4)+Q3(4,1))
=MIN(10,5+4)
=MIN(10,9)= 9
R S T U
R
S
T
U
7 5 0 0
7 0 0 2
0 3 0 0
4 0 1 0
W = 12Q2 =
10
7
5
11
Q3 =
4 6
Q4 = 3
8
6

More Related Content

What's hot

Dominating Sets, Multiple Egocentric Networks and Modularity Maximizing Clust...
Dominating Sets, Multiple Egocentric Networks and Modularity Maximizing Clust...Dominating Sets, Multiple Egocentric Networks and Modularity Maximizing Clust...
Dominating Sets, Multiple Egocentric Networks and Modularity Maximizing Clust...
Moses Boudourides
 
Cs6702 graph theory and applications 2 marks questions and answers
Cs6702 graph theory and applications 2 marks questions and answersCs6702 graph theory and applications 2 marks questions and answers
Cs6702 graph theory and applications 2 marks questions and answers
appasami
 
CS6702 graph theory and applications notes pdf book
CS6702 graph theory and applications notes pdf bookCS6702 graph theory and applications notes pdf book
CS6702 graph theory and applications notes pdf book
appasami
 
Notes 3-2
Notes 3-2Notes 3-2
Notes 3-2
Jimbo Lamb
 
Short version of Dominating Sets, Multiple Egocentric Networks and Modularity...
Short version of Dominating Sets, Multiple Egocentric Networks and Modularity...Short version of Dominating Sets, Multiple Egocentric Networks and Modularity...
Short version of Dominating Sets, Multiple Egocentric Networks and Modularity...
Moses Boudourides
 
Boudourides & Lenis, Distribution of Groups of Vertices Across Multilayer Net...
Boudourides & Lenis, Distribution of Groups of Vertices Across Multilayer Net...Boudourides & Lenis, Distribution of Groups of Vertices Across Multilayer Net...
Boudourides & Lenis, Distribution of Groups of Vertices Across Multilayer Net...
Moses Boudourides
 
Basics on Graph Theory
Basics on Graph TheoryBasics on Graph Theory
Basics on Graph Theory
Guillaume Guérard
 
Randomized algorithms all pairs shortest path
Randomized algorithms  all pairs shortest pathRandomized algorithms  all pairs shortest path
Randomized algorithms all pairs shortest path
Mohammad Akbarizadeh
 
Topics of Complex Social Networks: Domination, Influence and Assortativity
Topics of Complex Social Networks: Domination, Influence and AssortativityTopics of Complex Social Networks: Domination, Influence and Assortativity
Topics of Complex Social Networks: Domination, Influence and Assortativity
Moses Boudourides
 
Algorithm Design and Complexity - Course 8
Algorithm Design and Complexity - Course 8Algorithm Design and Complexity - Course 8
Algorithm Design and Complexity - Course 8Traian Rebedea
 
Strong (Weak) Triple Connected Domination Number of a Fuzzy Graph
Strong (Weak) Triple Connected Domination Number of a Fuzzy GraphStrong (Weak) Triple Connected Domination Number of a Fuzzy Graph
Strong (Weak) Triple Connected Domination Number of a Fuzzy Graph
ijceronline
 
Shortest Path Problem
Shortest Path ProblemShortest Path Problem
Shortest Path Problem
Guillaume Guérard
 
Algorithm Design and Complexity - Course 11
Algorithm Design and Complexity - Course 11Algorithm Design and Complexity - Course 11
Algorithm Design and Complexity - Course 11Traian Rebedea
 
Johnson's algorithm
Johnson's algorithmJohnson's algorithm
Johnson's algorithm
Kiran K
 
Equi independent equitable domination number of cycle and bistar related graphs
Equi independent equitable domination number of cycle and bistar related graphsEqui independent equitable domination number of cycle and bistar related graphs
Equi independent equitable domination number of cycle and bistar related graphs
iosrjce
 
Chapter 26 aoa
Chapter 26 aoaChapter 26 aoa
Chapter 26 aoa
Hanif Durad
 
20 Single Source Shorthest Path
20 Single Source Shorthest Path20 Single Source Shorthest Path
20 Single Source Shorthest Path
Andres Mendez-Vazquez
 
Chapter 23 aoa
Chapter 23 aoaChapter 23 aoa
Chapter 23 aoa
Hanif Durad
 
Inner product spaces
Inner product spacesInner product spaces
Inner product spaces
gidc engineering college
 
Prim's Algorithm on minimum spanning tree
Prim's Algorithm on minimum spanning treePrim's Algorithm on minimum spanning tree
Prim's Algorithm on minimum spanning tree
oneous
 

What's hot (20)

Dominating Sets, Multiple Egocentric Networks and Modularity Maximizing Clust...
Dominating Sets, Multiple Egocentric Networks and Modularity Maximizing Clust...Dominating Sets, Multiple Egocentric Networks and Modularity Maximizing Clust...
Dominating Sets, Multiple Egocentric Networks and Modularity Maximizing Clust...
 
Cs6702 graph theory and applications 2 marks questions and answers
Cs6702 graph theory and applications 2 marks questions and answersCs6702 graph theory and applications 2 marks questions and answers
Cs6702 graph theory and applications 2 marks questions and answers
 
CS6702 graph theory and applications notes pdf book
CS6702 graph theory and applications notes pdf bookCS6702 graph theory and applications notes pdf book
CS6702 graph theory and applications notes pdf book
 
Notes 3-2
Notes 3-2Notes 3-2
Notes 3-2
 
Short version of Dominating Sets, Multiple Egocentric Networks and Modularity...
Short version of Dominating Sets, Multiple Egocentric Networks and Modularity...Short version of Dominating Sets, Multiple Egocentric Networks and Modularity...
Short version of Dominating Sets, Multiple Egocentric Networks and Modularity...
 
Boudourides & Lenis, Distribution of Groups of Vertices Across Multilayer Net...
Boudourides & Lenis, Distribution of Groups of Vertices Across Multilayer Net...Boudourides & Lenis, Distribution of Groups of Vertices Across Multilayer Net...
Boudourides & Lenis, Distribution of Groups of Vertices Across Multilayer Net...
 
Basics on Graph Theory
Basics on Graph TheoryBasics on Graph Theory
Basics on Graph Theory
 
Randomized algorithms all pairs shortest path
Randomized algorithms  all pairs shortest pathRandomized algorithms  all pairs shortest path
Randomized algorithms all pairs shortest path
 
Topics of Complex Social Networks: Domination, Influence and Assortativity
Topics of Complex Social Networks: Domination, Influence and AssortativityTopics of Complex Social Networks: Domination, Influence and Assortativity
Topics of Complex Social Networks: Domination, Influence and Assortativity
 
Algorithm Design and Complexity - Course 8
Algorithm Design and Complexity - Course 8Algorithm Design and Complexity - Course 8
Algorithm Design and Complexity - Course 8
 
Strong (Weak) Triple Connected Domination Number of a Fuzzy Graph
Strong (Weak) Triple Connected Domination Number of a Fuzzy GraphStrong (Weak) Triple Connected Domination Number of a Fuzzy Graph
Strong (Weak) Triple Connected Domination Number of a Fuzzy Graph
 
Shortest Path Problem
Shortest Path ProblemShortest Path Problem
Shortest Path Problem
 
Algorithm Design and Complexity - Course 11
Algorithm Design and Complexity - Course 11Algorithm Design and Complexity - Course 11
Algorithm Design and Complexity - Course 11
 
Johnson's algorithm
Johnson's algorithmJohnson's algorithm
Johnson's algorithm
 
Equi independent equitable domination number of cycle and bistar related graphs
Equi independent equitable domination number of cycle and bistar related graphsEqui independent equitable domination number of cycle and bistar related graphs
Equi independent equitable domination number of cycle and bistar related graphs
 
Chapter 26 aoa
Chapter 26 aoaChapter 26 aoa
Chapter 26 aoa
 
20 Single Source Shorthest Path
20 Single Source Shorthest Path20 Single Source Shorthest Path
20 Single Source Shorthest Path
 
Chapter 23 aoa
Chapter 23 aoaChapter 23 aoa
Chapter 23 aoa
 
Inner product spaces
Inner product spacesInner product spaces
Inner product spaces
 
Prim's Algorithm on minimum spanning tree
Prim's Algorithm on minimum spanning treePrim's Algorithm on minimum spanning tree
Prim's Algorithm on minimum spanning tree
 

Viewers also liked

Internal Student Transcript - 2015 - University of Canterbury
Internal Student Transcript - 2015 - University of CanterburyInternal Student Transcript - 2015 - University of Canterbury
Internal Student Transcript - 2015 - University of CanterburyTamara Bell
 
Felix koch main stage - 2011
Felix koch   main stage - 2011Felix koch   main stage - 2011
Felix koch main stage - 2011
Ray Poynter
 
методика ноосферного уроку
методика ноосферного урокуметодика ноосферного уроку
методика ноосферного уроку
Elena Elena
 
Open Data Day report for Brigade meeting
Open Data Day report for Brigade meetingOpen Data Day report for Brigade meeting
Open Data Day report for Brigade meeting
CodeForTokyo
 
Kandidaatintyö_Lehtinen_ Miska
Kandidaatintyö_Lehtinen_ MiskaKandidaatintyö_Lehtinen_ Miska
Kandidaatintyö_Lehtinen_ MiskaMiska Lehtinen
 
European E-mail Marketing Consumer Report 2010 (estratto)
European E-mail Marketing Consumer Report 2010 (estratto) European E-mail Marketing Consumer Report 2010 (estratto)
European E-mail Marketing Consumer Report 2010 (estratto) Contactlab
 
Andrien Ang_CV (Malaysia)
Andrien Ang_CV (Malaysia)Andrien Ang_CV (Malaysia)
Andrien Ang_CV (Malaysia)Andrien Ang
 
О формировании кластера непрерывного казачьего образования. Иванова Валентин...
 О формировании кластера непрерывного казачьего образования. Иванова Валентин... О формировании кластера непрерывного казачьего образования. Иванова Валентин...
О формировании кластера непрерывного казачьего образования. Иванова Валентин...
TCenter500
 
О Фестивале юных экологов и туристов, приуроченном к открытию фотовыставки «В...
О Фестивале юных экологов и туристов, приуроченном к открытию фотовыставки «В...О Фестивале юных экологов и туристов, приуроченном к открытию фотовыставки «В...
О Фестивале юных экологов и туристов, приуроченном к открытию фотовыставки «В...
TCenter500
 
О проектах «Университетские субботы», «Профессиональные среды»
О проектах «Университетские субботы», «Профессиональные среды» О проектах «Университетские субботы», «Профессиональные среды»
О проектах «Университетские субботы», «Профессиональные среды»
TCenter500
 
Richard Ong-resume2016July08
Richard Ong-resume2016July08Richard Ong-resume2016July08
Richard Ong-resume2016July08Richard ong
 

Viewers also liked (16)

Qrm jan 2016 slide (welcome)
Qrm jan 2016 slide (welcome)Qrm jan 2016 slide (welcome)
Qrm jan 2016 slide (welcome)
 
Internal Student Transcript - 2015 - University of Canterbury
Internal Student Transcript - 2015 - University of CanterburyInternal Student Transcript - 2015 - University of Canterbury
Internal Student Transcript - 2015 - University of Canterbury
 
Felix koch main stage - 2011
Felix koch   main stage - 2011Felix koch   main stage - 2011
Felix koch main stage - 2011
 
методика ноосферного уроку
методика ноосферного урокуметодика ноосферного уроку
методика ноосферного уроку
 
Mbwfjglssysept03bkltspjan05
Mbwfjglssysept03bkltspjan05Mbwfjglssysept03bkltspjan05
Mbwfjglssysept03bkltspjan05
 
resume
resumeresume
resume
 
ANIVERSARIS DE JUNY
ANIVERSARIS  DE  JUNYANIVERSARIS  DE  JUNY
ANIVERSARIS DE JUNY
 
CV_LEC
CV_LECCV_LEC
CV_LEC
 
Open Data Day report for Brigade meeting
Open Data Day report for Brigade meetingOpen Data Day report for Brigade meeting
Open Data Day report for Brigade meeting
 
Kandidaatintyö_Lehtinen_ Miska
Kandidaatintyö_Lehtinen_ MiskaKandidaatintyö_Lehtinen_ Miska
Kandidaatintyö_Lehtinen_ Miska
 
European E-mail Marketing Consumer Report 2010 (estratto)
European E-mail Marketing Consumer Report 2010 (estratto) European E-mail Marketing Consumer Report 2010 (estratto)
European E-mail Marketing Consumer Report 2010 (estratto)
 
Andrien Ang_CV (Malaysia)
Andrien Ang_CV (Malaysia)Andrien Ang_CV (Malaysia)
Andrien Ang_CV (Malaysia)
 
О формировании кластера непрерывного казачьего образования. Иванова Валентин...
 О формировании кластера непрерывного казачьего образования. Иванова Валентин... О формировании кластера непрерывного казачьего образования. Иванова Валентин...
О формировании кластера непрерывного казачьего образования. Иванова Валентин...
 
О Фестивале юных экологов и туристов, приуроченном к открытию фотовыставки «В...
О Фестивале юных экологов и туристов, приуроченном к открытию фотовыставки «В...О Фестивале юных экологов и туристов, приуроченном к открытию фотовыставки «В...
О Фестивале юных экологов и туристов, приуроченном к открытию фотовыставки «В...
 
О проектах «Университетские субботы», «Профессиональные среды»
О проектах «Университетские субботы», «Профессиональные среды» О проектах «Университетские субботы», «Профессиональные среды»
О проектах «Университетские субботы», «Профессиональные среды»
 
Richard Ong-resume2016July08
Richard Ong-resume2016July08Richard Ong-resume2016July08
Richard Ong-resume2016July08
 

Similar to Graph

DATA STRUCTURES.pptx
DATA STRUCTURES.pptxDATA STRUCTURES.pptx
DATA STRUCTURES.pptx
KENNEDY GITHAIGA
 
graph_theory_1-11.pdf___________________
graph_theory_1-11.pdf___________________graph_theory_1-11.pdf___________________
graph_theory_1-11.pdf___________________
ssuser1989da
 
Lecture 5b graphs and hashing
Lecture 5b graphs and hashingLecture 5b graphs and hashing
Lecture 5b graphs and hashingVictor Palmar
 
lec 09-graphs-bfs-dfs.ppt
lec 09-graphs-bfs-dfs.pptlec 09-graphs-bfs-dfs.ppt
lec 09-graphs-bfs-dfs.ppt
TalhaFarooqui12
 
Graph Theory,Graph Terminologies,Planar Graph & Graph Colouring
Graph Theory,Graph Terminologies,Planar Graph & Graph ColouringGraph Theory,Graph Terminologies,Planar Graph & Graph Colouring
Graph Theory,Graph Terminologies,Planar Graph & Graph Colouring
Saurabh Kaushik
 
Cs6702 2marks rejinpaul
Cs6702 2marks rejinpaulCs6702 2marks rejinpaul
Cs6702 2marks rejinpaul
stalinjothi
 
6. Graphs
6. Graphs6. Graphs
6. Graphs
Mandeep Singh
 
358 33 powerpoint-slides_13-graphs_chapter-13
358 33 powerpoint-slides_13-graphs_chapter-13358 33 powerpoint-slides_13-graphs_chapter-13
358 33 powerpoint-slides_13-graphs_chapter-13
sumitbardhan
 
Graph in Data Structure
Graph in Data StructureGraph in Data Structure
Graph in Data Structure
Prof Ansari
 
graph theory
graph theorygraph theory
graph theory
Shashank Singh
 
Elements of Graph Theory for IS.pptx
Elements of Graph Theory for IS.pptxElements of Graph Theory for IS.pptx
Elements of Graph Theory for IS.pptx
miki304759
 
graph ASS (1).ppt
graph ASS (1).pptgraph ASS (1).ppt
graph ASS (1).ppt
ARVIND SARDAR
 
Graphs
GraphsGraphs
Graphs
amudha arul
 
09_DS_MCA_Graphs.pdf
09_DS_MCA_Graphs.pdf09_DS_MCA_Graphs.pdf
09_DS_MCA_Graphs.pdf
Prasanna David
 
Graph ASS DBATU.pptx
Graph ASS DBATU.pptxGraph ASS DBATU.pptx
Graph ASS DBATU.pptx
ARVIND SARDAR
 
Introduction to Graph Theory
Introduction to Graph TheoryIntroduction to Graph Theory
Introduction to Graph Theory
Premsankar Chakkingal
 
Graph terminology and algorithm and tree.pptx
Graph terminology and algorithm and tree.pptxGraph terminology and algorithm and tree.pptx
Graph terminology and algorithm and tree.pptx
asimshahzad8611
 
Matrix representation of graph
Matrix representation of graphMatrix representation of graph
Matrix representation of graph
Rounak Biswas
 

Similar to Graph (20)

logic.pptx
logic.pptxlogic.pptx
logic.pptx
 
DATA STRUCTURES.pptx
DATA STRUCTURES.pptxDATA STRUCTURES.pptx
DATA STRUCTURES.pptx
 
graph_theory_1-11.pdf___________________
graph_theory_1-11.pdf___________________graph_theory_1-11.pdf___________________
graph_theory_1-11.pdf___________________
 
Lecture 5b graphs and hashing
Lecture 5b graphs and hashingLecture 5b graphs and hashing
Lecture 5b graphs and hashing
 
lec 09-graphs-bfs-dfs.ppt
lec 09-graphs-bfs-dfs.pptlec 09-graphs-bfs-dfs.ppt
lec 09-graphs-bfs-dfs.ppt
 
Graph Theory,Graph Terminologies,Planar Graph & Graph Colouring
Graph Theory,Graph Terminologies,Planar Graph & Graph ColouringGraph Theory,Graph Terminologies,Planar Graph & Graph Colouring
Graph Theory,Graph Terminologies,Planar Graph & Graph Colouring
 
Cs6702 2marks rejinpaul
Cs6702 2marks rejinpaulCs6702 2marks rejinpaul
Cs6702 2marks rejinpaul
 
6. Graphs
6. Graphs6. Graphs
6. Graphs
 
358 33 powerpoint-slides_13-graphs_chapter-13
358 33 powerpoint-slides_13-graphs_chapter-13358 33 powerpoint-slides_13-graphs_chapter-13
358 33 powerpoint-slides_13-graphs_chapter-13
 
Graph in Data Structure
Graph in Data StructureGraph in Data Structure
Graph in Data Structure
 
graph theory
graph theorygraph theory
graph theory
 
Elements of Graph Theory for IS.pptx
Elements of Graph Theory for IS.pptxElements of Graph Theory for IS.pptx
Elements of Graph Theory for IS.pptx
 
graph ASS (1).ppt
graph ASS (1).pptgraph ASS (1).ppt
graph ASS (1).ppt
 
Graphs
GraphsGraphs
Graphs
 
09_DS_MCA_Graphs.pdf
09_DS_MCA_Graphs.pdf09_DS_MCA_Graphs.pdf
09_DS_MCA_Graphs.pdf
 
Graph ASS DBATU.pptx
Graph ASS DBATU.pptxGraph ASS DBATU.pptx
Graph ASS DBATU.pptx
 
Graph theory
Graph theoryGraph theory
Graph theory
 
Introduction to Graph Theory
Introduction to Graph TheoryIntroduction to Graph Theory
Introduction to Graph Theory
 
Graph terminology and algorithm and tree.pptx
Graph terminology and algorithm and tree.pptxGraph terminology and algorithm and tree.pptx
Graph terminology and algorithm and tree.pptx
 
Matrix representation of graph
Matrix representation of graphMatrix representation of graph
Matrix representation of graph
 

Recently uploaded

AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 

Recently uploaded (20)

AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 

Graph

  • 2. What is a Graph?  A data structure that consists of a set of nodes (vertices) and a set of edges that relate the nodes to each other  The set of edges describes relationships among the vertices
  • 3. A graph G consists of two things: 1.A set V of elements called nodes(or points or vertices) 2.A set E of edges such that each edge e in E is identified with a unique pair [u,v] of nodes in V, denoted by e=[u,v] Suppose e=[u,v]. Then the nodes u and v are called endpoints of e and u and v are said to be adjacent nodes or neighbors.
  • 5. Degree of a graph The degree of a node u, written as deg(u), is the number of edges containing u. If deg(u)=0 that is, if u does not belong to any edge then u is called an isolated node. A B C D E Nodes degree A 4 B 3 C 2 D 3 E 4 F 0F Isolated node
  • 6. Directed Graph  Each edge is assigned a direction or each edge E is identified with ordered pair (u,v)  (u,v) directed graph  [u,v] undirected graph  U=origin  v=destination
  • 7. Connected Graph A graph G is said to be connected graph if there is atleast one path between every pair of vertices in G. A graph which is not connected is called disconnected graph.
  • 8. Strongly Connected Graph A directed graph G is said to be strongly connected if foreach pairu,v of nodes in G there is a path fromu to v and there is also a path fromv to u.
  • 10. In simple words,  A strongly connected component (SCC) of a directed graph is a maximal strongly connected subgraph.
  • 11.
  • 12. Depth-First-Search (DFS)  The idea behind DFS is travel as far as you can down a path  DFS can be implemented efficiently using a stack .  This algorithm is similar to inorder traversal of a binary tree i.e. first of all we process the left node then root and then the right node.
  • 14. Kosaraju's algorithm  Kosaraju's algorithm (also known as the Kosaraju–Shariralgorithm) is a linear time algorithm to find the strongly connected components  of a directed graph.  It makes use of the fact that the transpose graph (the same graph with the direction of every edge reversed) has
  • 15. Algorithm 1) Let G be a directed graph and S be an empty stack. 2) Perform a depth-first search starting from any v.  3) Reverse the directions of all arcs to obtain the transpose graph. 4) Again perform depth-first search on transpose graph.
  • 16. A B C D E A B C D E
  • 17. A group of people are generally strongly connected (For example, students of a class or any other common place). Many people in these groups generally like some common pages or play common games. The SCC algorithms can be used to find such groups and suggest the commonly liked pages or games to the people in the group who have not yet liked commonly liked a page or played a game. Use of SCC algorithm in Social life
  • 18. MultigraphMultigraph  A graph G is said to be a multigraph if itA graph G is said to be a multigraph if it has:has: 1.1. multiple edgesmultiple edges 2.2. LoopsLoops A B C D e1 e7 e6 e5 e4 e3 e2
  • 19. Directed Graph  A directed graph G also called a digraph or graph is the same as multigraph except that each edge in G is assigned a direction. Outdegree= number of outgoing edges Indegree= number of incoming edges
  • 20. U- origin V - destination A B C D E Nodes Indegree outdegree A 0 4 B 1 1 C 2 1 D 3 0 E 1 1 Directed Graph
  • 21. Connected Graph A graph G is said to be connected graph if there is atleast one path between every pair of vertices in G. A graph which is not connected is called disconnected graph.
  • 22. Articulation PointArticulation Point  An articulation point in a connected graph is a vertex that, if delete would break the graph into two or more pieces (connected components).
  • 23.
  • 25. Biconnected GraphBiconnected Graph  A graph with no articulation point is called biconnected graph.  In other words, a graph is biconnected if and only if any vertex is deleted, the graph remains connected.
  • 27. Biconnected Components  A biconnected component of a graph is a maximal biconnected subgraph.  A biconnected subgraph that is not properly contained in a larger biconnected subgraph.
  • 28.
  • 33.  Let G be a directed graph with m nodes v1,v2…….,vm. Suppose we want to find the path matrix P of the graph G. Warshall gave an alogrithm for this purpose that is much more efficient than calculating the powers of the adjacency matrix A Warshall’s Algorithm: Shortest Paths
  • 34. Where adjacency matrix A =(aij) of the graph G is m x m matrix defined as follows: aij= 1 If vi is adjacent to vj, i.e. if there is an edge (vi,vj) 0 otherwise such a matrix A, which contains entries of only 0 and 1, is called a bit matrix or a boolean matrix
  • 35.  This algorithm is used to find the shortest paths in G when G is weighted.  First we define m-square boolean matrices P0,P1…….,Pm as follows:  Let Pk[i,j] denote the i, j entry of the matrix Pk.
  • 36.  Then we define  Pk[i,j]= 1 ,if there is a simple path from vi to vj which does not use any other node except possibly v1,v2, …..,vk 0 ,otherwise In other words, P0[i,j]=1, if there is an edge from vi to vj P1[i,j]=1, if there is a simple path from vi to vj which does not use any other node except possibly v1. P2[i,j]=1, if there is a simple path from vi to vj which does not use any other node except possibly v1 and v2.
  • 37.  Observe that P0=A, the adjacency matrix of G.  Since G has only m nodes, the last matrix Pm=P, the path matrix of G.  Warshall observed that Pk[i,j]=1 can occur only if one of the following two cases occur: 1. There is a simple path from vi to vj which does not use any other node except possibly v1,v2, ….,vk-1, hence Pk-1[i,j]=1 vi ……….. vj
  • 38. 2. There is a simple path from vi to vk and a simple path from vk to vj where each path does not use any other nodes except possibly v1,v2,……,vk-1; hence Pk-1[i,k]=1 and Pk-1[k,j]=1 vi ……….. ………..vk vj
  • 39.  Accordingly, the elements of matrix Pk can be obtained by: Pk[i,j]=Pk-1[i,j] v (Pk-1[i,k] Pk-1[k,j]) Where V and denote the logical OR and AND operator ^ 0 1 0 0 0 1 0 1 v 0 1 0 0 1 1 1 1
  • 40. A B CD 0 0 0 0 1 0 1 0 0 0 0 1 1 0 0 0 P0 =
  • 41.  P1[1,1]=P0[1,1]v(P0[1,1]^P0[1,1]) =0v(0^0) =0v0=0  P1[1,2]=P0[1,2]v(P0[1,1]^P0[1,2]) =0v(0^0) =0v0=0  P1[1,3]=P0[1,3]v(P0[1,1]^P0[1,3]) =0v(0^0) =0v0=0  P1[1,4]=P0[1,4]v(P0[1,1]^P0[1,4]) =0v(0^0) =0v0=0 P1[2,1]=P0[2,1]v(P0[2,1]^P0[1,1]) =1v(1^0) =1v0=1 P1[2,2]=P0[2,2]v(P0[2,1]^P0[1,2]) =0v(1^0) =0v0=0 P1[2,3]=P0[2,3]v(P0[2,1]^P0[1,3]) =1v(1^0) =1v0=1 P1[2,4]=P0[2,4]v(P0[2,1]^P0[1,4]) =0v(1^0) =0v0=0 P1 = 0 0 0 0 1 0 1 0 - - - - - - - -
  • 42. Shortest path algorithm  Let G be a directed graph with m nodes v1,v2,…..vm.  Suppose G is weighted i.e. suppose each edge e in G is assigned a non negative number w(e) called the weight or length of the edge e.
  • 43. Then G is maintained in memory by its weight matrix W=(wij) defined as: Wij= W(e), if there is an edge e from vi to vj 0, if there is no edge from vi to vj
  • 44.  Path matrix P tells us whether or not there are paths between the nodes.  Now we want to find a matrix Q which tell us the lengths of the shortest paths between the nodes or a matrix Q=(qij) where qij= length of shortest path from vi to vj.  Here we define a sequence of matrices Q1,Q2,…..Qm defined as Qk[i,j]= the smaller of the length of the preceding paths from vi to vj or the sum of the lengths of preceeding paths from vi to vk and from vk to vj. Qk[i,j]=min(Qk-1[i,j],Qk-1[i,k]+Qk-1[k,j])
  • 45. R U S T W = R S T U R S T U 4 1275 3 7 5 0 0 7 7 0 0 2 0 3 0 0 4 0 1 0
  • 46. R S T U R S T U 7 5 0 0 7 0 0 2 0 3 0 0 4 0 1 0 W =Q0 =
  • 47. Q1(1,1) =MIN(Q0(1,1),Q0(1,1)+Q0(1,1)) =MIN(7,7+7) =MIN(7,14)= 7 Q1(1,2) =MIN(Q0(1,2),Q0(1,1)+Q0(1,2)) =MIN(5,7+5) =MIN(5,12)= 5 Q1(2,1) =MIN(Q0(2,1),Q0(2,1)+Q0(1,1)) =MIN(7,7+7) =MIN(7,14)= 7 Q1(3,1) =MIN(Q0(3,1),Q0(3,1)+Q0(1,1)) =MIN( , +7) =MIN( ,14 )= 7
  • 48. R S T U R S T U 7 5 0 0 7 0 0 2 0 3 0 0 4 0 1 0 W =Q0 =Q1 = 12
  • 49. Q2(1,1) =MIN(Q1(1,1),Q1(1,1)+Q1(1,1)) =MIN(7,5+7) =MIN(7,12)= 7 Q1(1,3) =MIN(Q1(1,3),Q1(1,2)+Q1(2,3)) =MIN( , 5+ ) =MIN( ,14 )= 7 Similarly, proceeding like this we get a new matrix....
  • 50. R S T U R S T U 7 5 0 0 7 0 0 2 0 3 0 0 4 0 1 0 W =Q0 =Q1 = 12Q2 = 10 7 5 11
  • 51. Q3(1,1) =MIN(Q2(1,1),Q2(1,3)+Q2(3,1)) =MIN(7, +10) =MIN(7, )= 7 Q3(2,1) =MIN(Q2(2,1),Q2(2,3)+Q2(3,1)) =MIN(7, +5) =MIN(7, ) = 7 Q3(3,1) =MIN(Q2(3,1),Q2(3,3)+Q2(1,3)) =MIN(10, +7 ) =MIN(10,14 )= 10 Similarly, proceeding like this we get a new matrix....
  • 52. R S T U R S T U 7 5 0 0 7 0 0 2 0 3 0 0 4 0 1 0 W = 12Q2 = 10 7 5 11 Q3 = 4 6
  • 53. Q4(1,1) =MIN(Q3(1,1),Q3(1,4)+Q3(4,1)) =MIN(7,7+4) =MIN(7,11)= 7 Q4(2,1) =MIN(Q3(2,1),Q3(2,4)+Q3(4,1)) =MIN(7,2+4) =MIN(7,6)= 6 Q4(3,1) =MIN(Q3(3,1),Q3(2,4)+Q3(4,1)) =MIN(10,5+4) =MIN(10,9)= 9
  • 54. R S T U R S T U 7 5 0 0 7 0 0 2 0 3 0 0 4 0 1 0 W = 12Q2 = 10 7 5 11 Q3 = 4 6 Q4 = 3 8 6