Skip to main content

adjacency_list_of

Function adjacency_list_of 

Source
pub fn adjacency_list_of(graph: &Graph) -> String
Expand description

Returns the whole graph as text: one line per node with its out-nodes, in ascending order.

Each line ends with a line feed. For the control flow of a method with a loop:

let text = graphs::adjacency_list_of(&cfg);
// 0 -> [1]
// 1 -> [2, 5]
// 2 -> [3, 4]
// 3 -> [4]
// 4 -> [1]
// 5 -> []

Unlike the Display form of a graph, which is cut short for large graphs, this lists every node and edge; the graph of a BiAdjacentGraph lists its out-nodes.

Time: O(node_count + edge_count). Memory: 1 byte per character for the result; while it runs, about as much again.