graph_theory

advertisement
Graph Theory
By:
Maciej Kicinski
Chiu 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 7
S1 – {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 node
 For 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 connected
SCC 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 Graph
Can reduce # of nodes
since we know the
relation in simplicial
complexes we then
only need to find
relation 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 singles
Build Nodes – O(n*log(n))
or
Build Edges – O(n)
or
O(n*log(n))
O(n)
Tarjan Algorithm finished on ≈1 mil nodes in less
than a second.
Download