Skip to main content

of

Function of 

Source
pub fn of(graph: &Graph) -> Result<Vec<u32>, GraphError>
Expand description

Returns the nodes of graph in topological order: for every edge u -> v, u comes before v.

The result is a vector the caller owns - Java returns an unmodifiable IntList.

Time: O(node_count + edge_count). Memory: 4 x node_count bytes for the result; while it runs, 2 bits per node and up to 8 x node_count bytes for the stack, which grows with the deepest path.

§Errors

An InvalidArgument error, “graph contains a cycle”, if graph has a cycle, a self-loop included.

§Panics

With an invalid argument message if a depth-first path is longer than 2^30 - 5 nodes.