22
Graph Theory By: Maciej Kicinski Chiu Ming Luk

Graph Theory By: Maciej Kicinski Chiu Ming Luk. Extract Triple words

Embed Size (px)

Citation preview

Page 1: Graph Theory By: Maciej Kicinski Chiu Ming Luk. Extract Triple words

Graph Theory

By:Maciej KicinskiChiu Ming Luk

Page 2: Graph Theory By: Maciej Kicinski Chiu Ming Luk. Extract Triple words

Extract Triple words                            

Page 3: Graph Theory By: Maciej Kicinski Chiu Ming Luk. Extract Triple words

Extract Triple words                            

Page 4: Graph Theory By: Maciej Kicinski Chiu Ming Luk. Extract Triple words

Extract Double words                            

Page 5: Graph Theory By: Maciej Kicinski Chiu Ming Luk. Extract Triple words

Extract Double words                            

Page 6: Graph Theory By: Maciej Kicinski Chiu Ming Luk. Extract Triple words

Adjacency-matrix Representation                            

Page 7: Graph Theory By: Maciej Kicinski Chiu Ming Luk. Extract Triple words

Adjacency-matrix Representation                            

Page 8: Graph Theory By: Maciej Kicinski Chiu Ming Luk. Extract Triple words

Adjacency-lists Representation                            

Page 9: Graph Theory By: Maciej Kicinski Chiu Ming Luk. Extract Triple words

Depth-First Search                            

Page 10: Graph Theory By: Maciej Kicinski Chiu Ming Luk. Extract Triple words

Depth-First Search                            

Page 11: Graph Theory By: Maciej Kicinski Chiu Ming Luk. Extract Triple words

Breath-First Search                            

Page 12: Graph Theory By: Maciej Kicinski Chiu Ming Luk. Extract Triple words

Breath-First Search                            

Page 13: Graph Theory By: Maciej Kicinski Chiu Ming Luk. Extract Triple words

Strongly connected Component                            

Page 14: Graph Theory By: Maciej Kicinski Chiu Ming Luk. Extract Triple words

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.

Page 15: Graph Theory By: Maciej Kicinski Chiu Ming Luk. Extract Triple words

Kosaraju's algorithm                            

Page 16: Graph Theory By: Maciej Kicinski Chiu Ming Luk. Extract Triple words

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}

Page 17: Graph Theory By: Maciej Kicinski Chiu Ming Luk. Extract Triple words

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.

Page 18: Graph Theory By: Maciej Kicinski Chiu Ming Luk. Extract Triple words

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

Page 19: Graph Theory By: Maciej Kicinski Chiu Ming Luk. Extract Triple words

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}

Page 20: Graph Theory By: Maciej Kicinski Chiu Ming Luk. Extract Triple words

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}

Page 21: Graph Theory By: Maciej Kicinski Chiu Ming Luk. Extract Triple words

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}

Page 22: Graph Theory By: Maciej Kicinski Chiu Ming Luk. Extract Triple words

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.