Topological Ordering of Connected Components

Find a topological ordering of connected graph components.

    
Reordering vertices by connected components:
View the graphs and compare adjacency matrices before and after the reordering of vertices: