Graph

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.
Graph
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).
Graph
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.
Graph
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
1 de 54

Recomendados

Graph theory por
Graph theoryGraph theory
Graph theoryMuthulakshmilakshmi2
906 visualizações21 slides
DIGITAL TEXT BOOK por
DIGITAL TEXT BOOKDIGITAL TEXT BOOK
DIGITAL TEXT BOOKshinyvarghese1991
289 visualizações48 slides
Graph theory concepts complex networks presents-rouhollah nabati por
Graph theory concepts   complex networks presents-rouhollah nabatiGraph theory concepts   complex networks presents-rouhollah nabati
Graph theory concepts complex networks presents-rouhollah nabatinabati
2.8K visualizações107 slides
Multilayerity within multilayerity? On multilayer assortativity in social net... por
Multilayerity within multilayerity? On multilayer assortativity in social net...Multilayerity within multilayerity? On multilayer assortativity in social net...
Multilayerity within multilayerity? On multilayer assortativity in social net...Moses Boudourides
479 visualizações14 slides
Introduction to Graph Theory por
Introduction to Graph TheoryIntroduction to Graph Theory
Introduction to Graph TheoryYosuke Mizutani
4.2K visualizações71 slides
Graph por
GraphGraph
GraphMudassar Mushtaq
412 visualizações52 slides

Mais conteúdo relacionado

Mais procurados

Dominating Sets, Multiple Egocentric Networks and Modularity Maximizing Clust... por
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
962 visualizações38 slides
Cs6702 graph theory and applications 2 marks questions and answers por
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 answersappasami
13.5K visualizações15 slides
CS6702 graph theory and applications notes pdf book por
CS6702 graph theory and applications notes pdf bookCS6702 graph theory and applications notes pdf book
CS6702 graph theory and applications notes pdf bookappasami
58.9K visualizações153 slides
Notes 3-2 por
Notes 3-2Notes 3-2
Notes 3-2Jimbo Lamb
586 visualizações10 slides
Short version of Dominating Sets, Multiple Egocentric Networks and Modularity... por
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
877 visualizações28 slides
Boudourides & Lenis, Distribution of Groups of Vertices Across Multilayer Net... por
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
453 visualizações6 slides

Mais procurados(20)

Dominating Sets, Multiple Egocentric Networks and Modularity Maximizing Clust... por Moses Boudourides
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 Boudourides962 visualizações
Cs6702 graph theory and applications 2 marks questions and answers por appasami
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
appasami13.5K visualizações
CS6702 graph theory and applications notes pdf book por appasami
CS6702 graph theory and applications notes pdf bookCS6702 graph theory and applications notes pdf book
CS6702 graph theory and applications notes pdf book
appasami58.9K visualizações
Notes 3-2 por Jimbo Lamb
Notes 3-2Notes 3-2
Notes 3-2
Jimbo Lamb586 visualizações
Short version of Dominating Sets, Multiple Egocentric Networks and Modularity... por Moses Boudourides
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 Boudourides877 visualizações
Boudourides & Lenis, Distribution of Groups of Vertices Across Multilayer Net... por 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...
Moses Boudourides453 visualizações
Basics on Graph Theory por Guillaume Guérard
Basics on Graph TheoryBasics on Graph Theory
Basics on Graph Theory
Guillaume Guérard1.3K visualizações
Randomized algorithms all pairs shortest path por Mohammad Akbarizadeh
Randomized algorithms  all pairs shortest pathRandomized algorithms  all pairs shortest path
Randomized algorithms all pairs shortest path
Mohammad Akbarizadeh118 visualizações
Topics of Complex Social Networks: Domination, Influence and Assortativity por Moses Boudourides
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 Boudourides743 visualizações
Algorithm Design and Complexity - Course 8 por Traian Rebedea
Algorithm Design and Complexity - Course 8Algorithm Design and Complexity - Course 8
Algorithm Design and Complexity - Course 8
Traian Rebedea18.2K visualizações
Strong (Weak) Triple Connected Domination Number of a Fuzzy Graph por ijceronline
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
ijceronline838 visualizações
Shortest Path Problem por Guillaume Guérard
Shortest Path ProblemShortest Path Problem
Shortest Path Problem
Guillaume Guérard999 visualizações
Algorithm Design and Complexity - Course 11 por Traian Rebedea
Algorithm Design and Complexity - Course 11Algorithm Design and Complexity - Course 11
Algorithm Design and Complexity - Course 11
Traian Rebedea2.7K visualizações
Johnson's algorithm por Kiran K
Johnson's algorithmJohnson's algorithm
Johnson's algorithm
Kiran K708 visualizações
Equi independent equitable domination number of cycle and bistar related graphs por iosrjce
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
iosrjce253 visualizações
Chapter 26 aoa por Hanif Durad
Chapter 26 aoaChapter 26 aoa
Chapter 26 aoa
Hanif Durad449 visualizações
20 Single Source Shorthest Path por Andres Mendez-Vazquez
20 Single Source Shorthest Path20 Single Source Shorthest Path
20 Single Source Shorthest Path
Andres Mendez-Vazquez919 visualizações
Chapter 23 aoa por Hanif Durad
Chapter 23 aoaChapter 23 aoa
Chapter 23 aoa
Hanif Durad209 visualizações
Prim's Algorithm on minimum spanning tree por oneous
Prim's Algorithm on minimum spanning treePrim's Algorithm on minimum spanning tree
Prim's Algorithm on minimum spanning tree
oneous49.3K visualizações

Destaque

Internal Student Transcript - 2015 - University of Canterbury por
Internal Student Transcript - 2015 - University of CanterburyInternal Student Transcript - 2015 - University of Canterbury
Internal Student Transcript - 2015 - University of CanterburyTamara Bell
442 visualizações3 slides
Felix koch main stage - 2011 por
Felix koch   main stage - 2011Felix koch   main stage - 2011
Felix koch main stage - 2011Ray Poynter
726 visualizações36 slides
методика ноосферного уроку por
методика ноосферного урокуметодика ноосферного уроку
методика ноосферного урокуElena Elena
337 visualizações12 slides
Mbwfjglssysept03bkltspjan05 por
Mbwfjglssysept03bkltspjan05Mbwfjglssysept03bkltspjan05
Mbwfjglssysept03bkltspjan05Elizabeth Jimenez
193 visualizações40 slides
resume por
resumeresume
resumeChristopher Steininger
138 visualizações2 slides

Destaque(16)

Internal Student Transcript - 2015 - University of Canterbury por Tamara Bell
Internal Student Transcript - 2015 - University of CanterburyInternal Student Transcript - 2015 - University of Canterbury
Internal Student Transcript - 2015 - University of Canterbury
Tamara Bell442 visualizações
Felix koch main stage - 2011 por Ray Poynter
Felix koch   main stage - 2011Felix koch   main stage - 2011
Felix koch main stage - 2011
Ray Poynter726 visualizações
методика ноосферного уроку por Elena Elena
методика ноосферного урокуметодика ноосферного уроку
методика ноосферного уроку
Elena Elena337 visualizações
Mbwfjglssysept03bkltspjan05 por Elizabeth Jimenez
Mbwfjglssysept03bkltspjan05Mbwfjglssysept03bkltspjan05
Mbwfjglssysept03bkltspjan05
Elizabeth Jimenez193 visualizações
Open Data Day report for Brigade meeting por CodeForTokyo
Open Data Day report for Brigade meetingOpen Data Day report for Brigade meeting
Open Data Day report for Brigade meeting
CodeForTokyo517 visualizações
Kandidaatintyö_Lehtinen_ Miska por Miska Lehtinen
Kandidaatintyö_Lehtinen_ MiskaKandidaatintyö_Lehtinen_ Miska
Kandidaatintyö_Lehtinen_ Miska
Miska Lehtinen1.2K visualizações
European E-mail Marketing Consumer Report 2010 (estratto) por Contactlab
European E-mail Marketing Consumer Report 2010 (estratto) European E-mail Marketing Consumer Report 2010 (estratto)
European E-mail Marketing Consumer Report 2010 (estratto)
Contactlab472 visualizações
Andrien Ang_CV (Malaysia) por Andrien Ang
Andrien Ang_CV (Malaysia)Andrien Ang_CV (Malaysia)
Andrien Ang_CV (Malaysia)
Andrien Ang130 visualizações
О формировании кластера непрерывного казачьего образования. Иванова Валентин... por TCenter500
 О формировании кластера непрерывного казачьего образования. Иванова Валентин... О формировании кластера непрерывного казачьего образования. Иванова Валентин...
О формировании кластера непрерывного казачьего образования. Иванова Валентин...
TCenter5002.7K visualizações
О Фестивале юных экологов и туристов, приуроченном к открытию фотовыставки «В... por TCenter500
О Фестивале юных экологов и туристов, приуроченном к открытию фотовыставки «В...О Фестивале юных экологов и туристов, приуроченном к открытию фотовыставки «В...
О Фестивале юных экологов и туристов, приуроченном к открытию фотовыставки «В...
TCenter5003.9K visualizações
О проектах «Университетские субботы», «Профессиональные среды» por TCenter500
О проектах «Университетские субботы», «Профессиональные среды» О проектах «Университетские субботы», «Профессиональные среды»
О проектах «Университетские субботы», «Профессиональные среды»
TCenter5003.9K visualizações
Richard Ong-resume2016July08 por Richard ong
Richard Ong-resume2016July08Richard Ong-resume2016July08
Richard Ong-resume2016July08
Richard ong271 visualizações

Similar a Graph

logic.pptx por
logic.pptxlogic.pptx
logic.pptxKENNEDY GITHAIGA
4 visualizações58 slides
DATA STRUCTURES.pptx por
DATA STRUCTURES.pptxDATA STRUCTURES.pptx
DATA STRUCTURES.pptxKENNEDY GITHAIGA
8 visualizações59 slides
Lecture 5b graphs and hashing por
Lecture 5b graphs and hashingLecture 5b graphs and hashing
Lecture 5b graphs and hashingVictor Palmar
1.2K visualizações56 slides
lec 09-graphs-bfs-dfs.ppt por
lec 09-graphs-bfs-dfs.pptlec 09-graphs-bfs-dfs.ppt
lec 09-graphs-bfs-dfs.pptTalhaFarooqui12
4 visualizações106 slides
Graph Theory,Graph Terminologies,Planar Graph & Graph Colouring por
Graph Theory,Graph Terminologies,Planar Graph & Graph ColouringGraph Theory,Graph Terminologies,Planar Graph & Graph Colouring
Graph Theory,Graph Terminologies,Planar Graph & Graph ColouringSaurabh Kaushik
10.7K visualizações52 slides
Cs6702 2marks rejinpaul por
Cs6702 2marks rejinpaulCs6702 2marks rejinpaul
Cs6702 2marks rejinpaulstalinjothi
289 visualizações15 slides

Similar a Graph(20)

DATA STRUCTURES.pptx por KENNEDY GITHAIGA
DATA STRUCTURES.pptxDATA STRUCTURES.pptx
DATA STRUCTURES.pptx
KENNEDY GITHAIGA8 visualizações
Lecture 5b graphs and hashing por Victor Palmar
Lecture 5b graphs and hashingLecture 5b graphs and hashing
Lecture 5b graphs and hashing
Victor Palmar1.2K visualizações
lec 09-graphs-bfs-dfs.ppt por TalhaFarooqui12
lec 09-graphs-bfs-dfs.pptlec 09-graphs-bfs-dfs.ppt
lec 09-graphs-bfs-dfs.ppt
TalhaFarooqui124 visualizações
Graph Theory,Graph Terminologies,Planar Graph & Graph Colouring por Saurabh Kaushik
Graph Theory,Graph Terminologies,Planar Graph & Graph ColouringGraph Theory,Graph Terminologies,Planar Graph & Graph Colouring
Graph Theory,Graph Terminologies,Planar Graph & Graph Colouring
Saurabh Kaushik10.7K visualizações
Cs6702 2marks rejinpaul por stalinjothi
Cs6702 2marks rejinpaulCs6702 2marks rejinpaul
Cs6702 2marks rejinpaul
stalinjothi289 visualizações
6. Graphs por Mandeep Singh
6. Graphs6. Graphs
6. Graphs
Mandeep Singh100 visualizações
358 33 powerpoint-slides_13-graphs_chapter-13 por sumitbardhan
358 33 powerpoint-slides_13-graphs_chapter-13358 33 powerpoint-slides_13-graphs_chapter-13
358 33 powerpoint-slides_13-graphs_chapter-13
sumitbardhan3.9K visualizações
Graph in Data Structure por Prof Ansari
Graph in Data StructureGraph in Data Structure
Graph in Data Structure
Prof Ansari678 visualizações
graph theory por Shashank Singh
graph theorygraph theory
graph theory
Shashank Singh2.2K visualizações
Elements of Graph Theory for IS.pptx por miki304759
Elements of Graph Theory for IS.pptxElements of Graph Theory for IS.pptx
Elements of Graph Theory for IS.pptx
miki30475952 visualizações
graph ASS (1).ppt por ARVIND SARDAR
graph ASS (1).pptgraph ASS (1).ppt
graph ASS (1).ppt
ARVIND SARDAR33 visualizações
Graphs por amudha arul
GraphsGraphs
Graphs
amudha arul175 visualizações
09_DS_MCA_Graphs.pdf por Prasanna David
09_DS_MCA_Graphs.pdf09_DS_MCA_Graphs.pdf
09_DS_MCA_Graphs.pdf
Prasanna David10 visualizações
Graph ASS DBATU.pptx por ARVIND SARDAR
Graph ASS DBATU.pptxGraph ASS DBATU.pptx
Graph ASS DBATU.pptx
ARVIND SARDAR4 visualizações
Graph theory por Jeane Paguio
Graph theoryGraph theory
Graph theory
Jeane Paguio6.3K visualizações
Introduction to Graph Theory por Premsankar Chakkingal
Introduction to Graph TheoryIntroduction to Graph Theory
Introduction to Graph Theory
Premsankar Chakkingal35.1K visualizações
Matrix representation of graph por Rounak Biswas
Matrix representation of graphMatrix representation of graph
Matrix representation of graph
Rounak Biswas3.2K visualizações
Graphs por Dwight Sabio
GraphsGraphs
Graphs
Dwight Sabio763 visualizações

Último

The Research Portal of Catalonia: Growing more (information) & more (services) por
The Research Portal of Catalonia: Growing more (information) & more (services)The Research Portal of Catalonia: Growing more (information) & more (services)
The Research Portal of Catalonia: Growing more (information) & more (services)CSUC - Consorci de Serveis Universitaris de Catalunya
80 visualizações25 slides
PharoJS - Zürich Smalltalk Group Meetup November 2023 por
PharoJS - Zürich Smalltalk Group Meetup November 2023PharoJS - Zürich Smalltalk Group Meetup November 2023
PharoJS - Zürich Smalltalk Group Meetup November 2023Noury Bouraqadi
127 visualizações17 slides
Powerful Google developer tools for immediate impact! (2023-24) por
Powerful Google developer tools for immediate impact! (2023-24)Powerful Google developer tools for immediate impact! (2023-24)
Powerful Google developer tools for immediate impact! (2023-24)wesley chun
10 visualizações38 slides
Mini-Track: AI and ML in Network Operations Applications por
Mini-Track: AI and ML in Network Operations ApplicationsMini-Track: AI and ML in Network Operations Applications
Mini-Track: AI and ML in Network Operations ApplicationsNetwork Automation Forum
10 visualizações24 slides
Five Things You SHOULD Know About Postman por
Five Things You SHOULD Know About PostmanFive Things You SHOULD Know About Postman
Five Things You SHOULD Know About PostmanPostman
33 visualizações43 slides
Network Source of Truth and Infrastructure as Code revisited por
Network Source of Truth and Infrastructure as Code revisitedNetwork Source of Truth and Infrastructure as Code revisited
Network Source of Truth and Infrastructure as Code revisitedNetwork Automation Forum
26 visualizações45 slides

Último(20)

PharoJS - Zürich Smalltalk Group Meetup November 2023 por Noury Bouraqadi
PharoJS - Zürich Smalltalk Group Meetup November 2023PharoJS - Zürich Smalltalk Group Meetup November 2023
PharoJS - Zürich Smalltalk Group Meetup November 2023
Noury Bouraqadi127 visualizações
Powerful Google developer tools for immediate impact! (2023-24) por wesley chun
Powerful Google developer tools for immediate impact! (2023-24)Powerful Google developer tools for immediate impact! (2023-24)
Powerful Google developer tools for immediate impact! (2023-24)
wesley chun10 visualizações
Mini-Track: AI and ML in Network Operations Applications por Network Automation Forum
Mini-Track: AI and ML in Network Operations ApplicationsMini-Track: AI and ML in Network Operations Applications
Mini-Track: AI and ML in Network Operations Applications
Network Automation Forum10 visualizações
Five Things You SHOULD Know About Postman por Postman
Five Things You SHOULD Know About PostmanFive Things You SHOULD Know About Postman
Five Things You SHOULD Know About Postman
Postman33 visualizações
Network Source of Truth and Infrastructure as Code revisited por Network Automation Forum
Network Source of Truth and Infrastructure as Code revisitedNetwork Source of Truth and Infrastructure as Code revisited
Network Source of Truth and Infrastructure as Code revisited
Network Automation Forum26 visualizações
Scaling Knowledge Graph Architectures with AI por Enterprise Knowledge
Scaling Knowledge Graph Architectures with AIScaling Knowledge Graph Architectures with AI
Scaling Knowledge Graph Architectures with AI
Enterprise Knowledge30 visualizações
Democratising digital commerce in India-Report por Kapil Khandelwal (KK)
Democratising digital commerce in India-ReportDemocratising digital commerce in India-Report
Democratising digital commerce in India-Report
Kapil Khandelwal (KK)15 visualizações
MVP and prioritization.pdf por rahuldharwal141
MVP and prioritization.pdfMVP and prioritization.pdf
MVP and prioritization.pdf
rahuldharwal14131 visualizações
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive por Network Automation Forum
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLiveAutomating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Network Automation Forum31 visualizações
Piloting & Scaling Successfully With Microsoft Viva por Richard Harbridge
Piloting & Scaling Successfully With Microsoft VivaPiloting & Scaling Successfully With Microsoft Viva
Piloting & Scaling Successfully With Microsoft Viva
Richard Harbridge12 visualizações
Special_edition_innovator_2023.pdf por WillDavies22
Special_edition_innovator_2023.pdfSpecial_edition_innovator_2023.pdf
Special_edition_innovator_2023.pdf
WillDavies2217 visualizações
NET Conf 2023 Recap por Lee Richardson
NET Conf 2023 RecapNET Conf 2023 Recap
NET Conf 2023 Recap
Lee Richardson10 visualizações
Serverless computing with Google Cloud (2023-24) por wesley chun
Serverless computing with Google Cloud (2023-24)Serverless computing with Google Cloud (2023-24)
Serverless computing with Google Cloud (2023-24)
wesley chun11 visualizações
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas... por Bernd Ruecker
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
Bernd Ruecker37 visualizações
SUPPLIER SOURCING.pptx por angelicacueva6
SUPPLIER SOURCING.pptxSUPPLIER SOURCING.pptx
SUPPLIER SOURCING.pptx
angelicacueva615 visualizações
HTTP headers that make your website go faster - devs.gent November 2023 por Thijs Feryn
HTTP headers that make your website go faster - devs.gent November 2023HTTP headers that make your website go faster - devs.gent November 2023
HTTP headers that make your website go faster - devs.gent November 2023
Thijs Feryn22 visualizações
STKI Israeli Market Study 2023 corrected forecast 2023_24 v3.pdf por Dr. Jimmy Schwarzkopf
STKI Israeli Market Study 2023   corrected forecast 2023_24 v3.pdfSTKI Israeli Market Study 2023   corrected forecast 2023_24 v3.pdf
STKI Israeli Market Study 2023 corrected forecast 2023_24 v3.pdf
Dr. Jimmy Schwarzkopf19 visualizações

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.
  • 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).
  • 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.
  • 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