-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
impl topological sort of directed graph
- Loading branch information
Showing
2 changed files
with
108 additions
and
70 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 |
---|---|---|
@@ -1,13 +1,8 @@ | ||
use std::collections::HashSet; | ||
|
||
use algorithms_illuminated::graph::DirectedGraph; | ||
fn main() { | ||
let graph = DirectedGraph::build_from_file("src/graph/txt/graph_test2.txt").unwrap(); | ||
graph.print_graph(); | ||
let mut visited_set = HashSet::new(); | ||
let mut dfs_order = Vec::new(); | ||
let dfs_order = graph | ||
.dfs_recursive(0, &mut visited_set, &mut dfs_order) | ||
.unwrap(); | ||
println!("{:?}", dfs_order); | ||
let topo_sort = graph.topo_sort(); | ||
|
||
println!("{:?}", topo_sort); | ||
} |