Connected Components - Data Structures and Algorithms | CS 245, Study notes of Data Structures and Algorithms

Material Type: Notes; Professor: Galles; Class: Data Struct & Algorithms; Subject: Computer Science; University: University of San Francisco (CA); Term: Spring 2009;

Typology: Study notes

Pre 2010

Uploaded on 07/30/2009

koofers-user-a7u
koofers-user-a7u ๐Ÿ‡บ๐Ÿ‡ธ

10 documents

1 / 64

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Data Structures and Algorithms
CS245-2009S-21
Connected Components
David Galles
Department of Computer Science
University of San Francisco
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40

Partial preview of the text

Download Connected Components - Data Structures and Algorithms | CS 245 and more Study notes Data Structures and Algorithms in PDF only on Docsity!

Data Structures and Algorithms^ CS245-2009S-21Connected Components^ David GallesDepartment of Computer ScienceUniversity of San Francisco

21-0:^ Strongly Connected Graph^ Directed Path from every node to every other node^12

453 Strongly Connected

21-2:^ Connected Components^ Subgraph (subset of the vertices) that is stronglyconnected.

7 13 24

5 6 8

21-3:^ Connected Components^ Subgraph (subset of the vertices) that is stronglyconnected.

7 13 24

5 6 8

21-5:^ Connected Components^ Subgraph (subset of the vertices) that is stronglyconnected.

7 13 24

5 6 8

21-6:^ Connected Components^ Connected components of the graph are the^ largest possible^ strongly connected subgraphs^ If we put each vertex in its own component โ€“ eachcomponent would be (trivially) strongly connected^ Those would not be the connected componentsof the graph โ€“ unless there were no largerconnected subgraphs

21-8:^ DFS Revisited^ We can keep track of the order in which we visitthe elements in a Depth-First Search^ For any vertex v in a DFS:^ d[v] =^ Discovery^ time โ€“ when the vertex is firstvisited^ f[v] =^ Finishing^ time โ€“ when we have finishedwith a vertex (and all of its children)

21-9:^ DFS Revisited class Edge {public int neighbor;public int next;} void DFS(Edge G[], int vertex, boolean Visited[], int d[], int f[]) {Edge tmp;Visited[vertex] = true;d[vertex] = time++;for (tmp = G[vertex]; tmp != null; tmp = tmp.next) {if (!Visited[tmp.neighbor])DFS(G, tmp.neighbor, Visited);} f[vertex] = time++;}

21-11:^ DFS Example

7 13 24

5 6 8

21-12:^ DFS Example

dd ff

dd ff dd ff

dd ff

21-14:^ DFS Example

d 1d ff

dd ff d 2d ff

dd ff

21-15:^ DFS Example

d 1d^3 ff

dd ff d 2d ff

dd ff

21-17:^ DFS Example

d 1d^3 ff

dd ff d 2d^4 ff

d^5 d ff

21-18:^ DFS Example

d 1d^3 ff

dd ff d 2d^4 ff

d^5 d f^6 f