-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement kahn's algorithm for topological sorting (#259)
- Loading branch information
Showing
4 changed files
with
273 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,6 +129,7 @@ If you are interested, please contact us at [email protected] or contribute to | |
- [Graph Slicing based on connectivity](#graph-slicing-based-on-connectivity) | ||
- [Ford-Fulkerson Algorithm](#ford-fulkerson-algorithm) | ||
- [Kosaraju's Algorithm](#kosarajus-algorithm) | ||
- [Kahn's Algorithm](#kahn-algorithm) | ||
- [Partition Algorithm Explanation](#partition-algorithm-explanation) | ||
- [Vertex-Cut](#vertex-cut) | ||
- [Edge Balanced Vertex-Cut](#edge-balanced-vertex-cut) | ||
|
@@ -506,6 +507,10 @@ The idea behind the algorithm is as follows: as long as there is a path from the | |
2). Reverse directions of all arcs to obtain the transpose graph. | ||
3). One by one pop a vertex from S while S is not empty. Let the popped vertex be ‘v’. Take v as source and do DFS (call DFSUtil(v)). The DFS starting from v prints strongly connected component of v. | ||
|
||
### Kahn's Algorithm | ||
[Kahn's Algorithm](https://en.wikipedia.org/wiki/Topological_sorting#Kahn's_algorithm) finds topological | ||
ordering by iteratively removing nodes in the graph which have no incoming edges. When a node is removed from the graph, it is added to the topological ordering and all its edges are removed allowing for the next set of nodes with no incoming edges to be selected. | ||
|
||
## Partition Algorithm Explanation | ||
|
||
### Vertex-Cut | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.