tsort
Topological Sort
Functions
| Function | Description |
|---|---|
tsort_new | Create a graph with n nodes (labeled 0..n-1). |
tsort_add_edge | Add a directed edge from → to. |
tsort_sort | Topological sort using Kahn’s algorithm. Returns vec of node IDs in topologic… |
tsort_has_cycle | Check if graph has a cycle. |
tsort_node_count | Number of nodes. |
tsort_edge_count | Number of edges. |
Details
tsort_new
fn tsort_new(n: i64) -> &i64Create a graph with n nodes (labeled 0..n-1).
tsort_add_edge
fn tsort_add_edge(g: &i64, from: i64, to: i64)Add a directed edge from → to.
tsort_sort
fn tsort_sort(g: &i64) -> &i64Topological sort using Kahn’s algorithm. Returns vec of node IDs in topological order. If graph has a cycle, returns a vec shorter than node_count.
tsort_has_cycle
fn tsort_has_cycle(g: &i64) -> i64Check if graph has a cycle.
tsort_node_count
fn tsort_node_count(g: &i64) -> i64Number of nodes.
tsort_edge_count
fn tsort_edge_count(g: &i64) -> i64Number of edges.