Connected Components in Graph Theory - Prof. David J. Galles, Study notes of Data Structures and Algorithms

An in-depth explanation of connected components in graph theory. It covers the concepts of strongly connected graphs, connected components, and algorithms for finding connected components using depth-first search (dfs). The document also includes dfs algorithm implementation and examples.

Typology: Study notes

Pre 2010

Uploaded on 07/30/2009

koofers-user-7rn
koofers-user-7rn 🇺🇸

10 documents

1 / 25

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS245-2009S-21 Connected Components 1
21-0: Strongly Connected Graph
Directed Path from every node to every other node
1
2 3
4
5
Strongly Connected
21-1: Strongly Connected Graph
Directed Path from every node to every other node
1
2 3
4
5
Strongly Connected
21-2: Connected Components
Subgraph (subset of the vertices) that is strongly connected.
71
2
3
4
5
6 8
21-3: Connected Components
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19

Partial preview of the text

Download Connected Components in Graph Theory - Prof. David J. Galles and more Study notes Data Structures and Algorithms in PDF only on Docsity!

21-0: Strongly Connected Graph

  • Directed Path from every node to every other node
  • Strongly Connected

21-1: Strongly Connected Graph

  • Directed Path from every node to every other node
  • Strongly Connected

21-2: Connected Components

  • Subgraph (subset of the vertices) that is strongly connected.

1 7

21-3: Connected Components

  • Subgraph (subset of the vertices) that is strongly connected.

1 7

2

3

4

5

6 8

21-4: Connected Components

  • Subgraph (subset of the vertices) that is strongly connected.

1 7

21-5: Connected Components

  • Subgraph (subset of the vertices) that is strongly connected.

1 7

2

3

4

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 – each component would be (trivially) strongly connected
    • Those would not be the connected components of the graph – unless there were no larger connected subgraphs

21-12: DFS Example

d f

d f

d f

d f

d f

d f

d f

d f

21-13: DFS Example

d 1 f

d f

d f

d f

d f

d f

d f

d f

d 1 f

d f

d f

d f

d 2 f

d f

d f

d f

21-15: DFS Example

d 1 f

d 3 f

d f

d f

d 2 f

d f

d f

d f

d 1 f

d 3 f

d f

d f

d 2 f

d 4 f

d 5 f 6

d f

21-19: DFS Example

d 1 f

d 3 f

d f

d f

d 2 f

d 4 f 7

d 5 f 6

d f

d 1 f

d 3 f 8

d f

d f

d 2 f

d 4 f 7

d 5 f 6

d f

21-21: DFS Example

d 1 f

d 3 f 8

d f

d f

d 2 f 9

d 4 f 7

d 5 f 6

d f

1 7

2

3

4

5

6 8

d 1 f 10

d 3 f 8

d 11 f

d 12 f

d 2 f 9

d 4 f 7

d 5 f 6

d f

21-25: DFS Example

1 7

2

3

4

5

6 8

d 1 f 10

d 3 f 8

d 11 f

d 12 f 13

d 2 f 9

d 4 f 7

d 5 f 6

d f

1 7

2

3

4

5

6 8

d 1 f 10

d 3 f 8

d 11 f

d 12 f 13

d 2 f 9

d 4 f 7

d 5 f 6

d 14 f

21-27: DFS Example

1 7

2

3

4

5

6 8

d 1 f 10

d 3 f 8

d 11 f

d 12 f 13

d 2 f 9

d 4 f 7

d 5 f 6

d 14 f 15

d 1 f

d f

d f

d f

d f

d f

d f

d f 21-31: DFS Example

d 1 f

d f

d f

d f

d 2 f

d f

d f

d f

d 1 f

d f

d f

d f

d 2 f

d 3 f

d f

d f 21-33: DFS Example

d 1 f

d 4 f

d f

d f

d 2 f

d 3 f

d f

d f

d 1 f

d 4 f 7

d f

d f

d 2 f

d 3 f

d 5 f 6

d f 21-37: DFS Example

d 1 f

d 4 f 7

d f

d f

d 2 f

d 3 f 8

d 5 f 6

d f

d 1 f

d 4 f 7

d f

d f

d 2 f 9

d 3 f 8

d 5 f 6

d f 21-39: DFS Example

d 1 f 10

d 4 f 7

d f

d f

d 2 f 9

d 3 f 8

d 5 f 6

d f

1 7

2

3

4

5

6 8

d 1 f 10

d 4 f 7

d 11 f

d 13 f

d 2 f 9

d 3 f 8

d 5 f 6

d 12 f 21-43: DFS Example

1 7

2

3

4

5

6 8

d 1 f 10

d 4 f 7

d 11 f

d 13 f 14

d 2 f 9

d 3 f 8

d 5 f 6

d 12 f

1 7

2

3

4

5

6 8

d 1 f 10

d 4 f 7

d 11 f

d 13 f 14

d 2 f 9

d 3 f 8

d 5 f 6

d 12 f 15 21-45: DFS Example

1 7

2

3

4

5

6 8

d 1 f 10

d 4 f 7

d 11 f 16

d 13 f 14

d 2 f 9

d 3 f 8

d 5 f 6

d 12 f 15 21-46: Using d[] & f[]

  • Given two vertices v 1 and v 2 , what do we know if f [v 2 ] < f [v 1 ]?

21-47: Using d[] & f[]

  • Given two vertices v 1 and v 2 , what do we know if f [v 2 ] < f [v 1 ]?
    • Either:
      • Path from v 1 to v 2
        • Start from v 1
        • Eventually visit v 2
        • Finish v 2
        • Finish v 1

21-48: Using d[] & f[]