|
1632 | 1632 | - A **DAG**:
|
1633 | 1633 | - **Directed Acyclic Graph**
|
1634 | 1634 | - It's a directed graph G without any cycle
|
1635 |
| -- A **source** is a vertex with no incoming edges |
1636 |
| -- A **sink** is a vertex with no outgoing edges |
| 1635 | +- A **source** vertex is a vertex with no incoming edges |
| 1636 | +- A **sink** vertex is a vertex with no outgoing edges |
1637 | 1637 | - A Topological Sort:
|
1638 | 1638 | - Find sink; Put at end of order; Remove from graph; Repeat
|
1639 | 1639 | - It's the DFS algorithm
|
|
1656 | 1656 | - 2 vertices v, w in a directed graph are connected:
|
1657 | 1657 | - if you can reach v from w and can reach w from v
|
1658 | 1658 | - **Strongly connected graph**: is a directed graph where every vertex is reachable from every other vertex
|
1659 |
| -- **Strongly connected components**: It's a collection of subgraphs of an arbitrary directed graph that are strongly connected |
| 1659 | +- **Strongly connected components**, **SCC**: It's a collection of subgraphs of an arbitrary directed graph that are strongly connected |
1660 | 1660 | - **Metagraph**:
|
1661 | 1661 | - It's formed from all strongly connected components
|
1662 | 1662 | - Each stromgly connected components is represented by a vertice
|
1663 | 1663 | - **The metagraph of a directed graph is always a DAG**
|
| 1664 | +- **Sink Components** |
| 1665 | + - It's a subgrph of a directed graph with no outgoing edges |
| 1666 | + - If v is in a sink SCC, `explore (v)` finds this SCC |
| 1667 | +- **Source Components** |
| 1668 | + - It's a subgrph of a directed graph with no incoming edges |
| 1669 | + - The vertex with the largest postorder number is in a source component |
| 1670 | +- **Reverse Graph**, **G^R** |
| 1671 | + - It's a directed graph obtained from G by reversing the direction of all of its edges |
| 1672 | + - G^R and G have same SCCs |
| 1673 | + - Source components of G^R are sink components of G |
| 1674 | + - **The vertex with largest postorder in G^R is in a sink SCC of G** |
| 1675 | +- Find all SCCs of a directed graph G: |
| 1676 | + - SCCs (G, Gr): |
| 1677 | + Run DFS(Gr): |
| 1678 | + fir v ∈ V in reverse postorder: |
| 1679 | + if v isn't visited: |
| 1680 | + Explore(v, G): vertices found are first SCC |
| 1681 | + Mark visited vertices as new SCC |
| 1682 | + - Time Complexity: O(|V| + |E|) |
| 1683 | + - It's essentially DFS on Gr and then on G |
1664 | 1684 | - For more details:
|
1665 | 1685 | - UC San Diego Course:[Strongly Connected Components I](https://github.com/hamidgasmi/training.computerscience.algorithms-datastructures/blob/master/3-graph-algorithms/1_graph_decomposition/09_graph_decomposition_8_strongly-connected-components.pdf)
|
1666 | 1686 | - UC San Diego Course:[Strongly Connected Components II](https://github.com/hamidgasmi/training.computerscience.algorithms-datastructures/blob/master/3-graph-algorithms/1_graph_decomposition/09_graph_decomposition_9_computing-sccs.pdf)
|
|
0 commit comments