Upload
marjory-allen
View
220
Download
0
Tags:
Embed Size (px)
Citation preview
Graph Theory
By:Maciej KicinskiChiu Ming Luk
Extract Triple words
Extract Triple words
Extract Double words
Extract Double words
Adjacency-matrix Representation
Adjacency-matrix Representation
Adjacency-lists Representation
Depth-First Search
Depth-First Search
Breath-First Search
Breath-First Search
Strongly connected Component
Kosaraju's algorithm
• Let G be a directed graph and S be an empty stack.• While S does not contain all vertices:
– Choose an arbitrary vertex v not in S. Perform a depth-first search starting at v. Each time that depth-first search finishes expanding a vertex u, push u onto S.
• Reverse the directions of all arcs to obtain the transpose graph.• While S is nonempty:
– Pop the top vertex v from S. Perform a depth-first search starting at v. The set of visited vertices will give the strongly connected component containing v; record this and remove all these vertices from the graph G and the stack S.
Kosaraju's algorithm
Simplicial Complexes
S0 – 0 1 2 3 4 5 6 7S1 – {0,1} {0,2} {1,2} {3,4} {5,6} {5,7} {6,7}S2 - {5,6,7}
Tarjan Algorithm
For a directed graph:Checks every edge starting from a nodeFor every node lead to by an edge, checks edges for
nodes that have not been checked yet repeats until every node that can be checked from these nodes has been check
All checked nodes are Strongly Connected.
Any node that could not have been reached is not strongly connected to the nodes reached.
Tarjan Algorithm
To find Strong Connected Components(SCC)Take simplicial complexes:Δ0 – 0 1 2 3 4 5 6 7Δ1 – {0,1} {0,2} {1,2} {3,4} {5,6} {5,7} {6,7}Δ2 – {5,6,7}
And make each one a node with edges connecting relationΔ0 – 0 1 2 3 4 5 6 7Δ1 – 8 9 10 11 12 13 14Δ2 – 15
Graph
Δ0 – 0 1 2 3 4 5 6 7Δ1 – {0,1} {0,2} {1,2} {3,4} {5,6} {5,7} {6,7}Δ2 - {5,6,7}
Strongly Connected Components
Connected nodes are consider strongly connectedSCC 0 – 0 1 2 {0,1} {0,2} {1,2}SCC 1 – 3 4 {3,4}SCC 2 – 5 6 7 {5,6} {5,7} {6,7} {5,6,7}
Simplicial Complex and SCC GraphCan reduce # of nodessince we know therelation in simplicial complexes we then only need to findrelation between the different complexes.
SCC 0 – {0,1} {0,2} ({1,2})SCC 1 – {3,4}SCC 2 – {5,6,7}
Run Time
Tarjan Algorithm runs in O(e + n) time where e is edges and n is number of nodes
Sort – O(n*log(n)) but only on singlesBuild Nodes – O(n*log(n)) or O(n)Build Edges – O(n) orO(n*log(n))
Tarjan Algorithm finished on ≈1 mil nodes in less than a second.