Graph.adjacencyList

Get the adjacencyList of this graph where nodes are represented by their index in the nodes list.

struct Graph(Node, Weight = void, Flag!"isDirected" isDirected = No.isDirected, EdgePayload = void)
const
static if(!(isDirected))
size_t[][]
adjacencyList
()

Examples

auto g1 = Graph!int([1, 2, 3, 4]);

g1 ~= g1.edge(1, 1);
g1 ~= g1.edge(1, 2);
g1 ~= g1.edge(2, 2);
g1 ~= g1.edge(2, 3);
g1 ~= g1.edge(2, 4);
g1 ~= g1.edge(3, 4);

assert(g1.adjacencyList() == [
    [0, 1],
    [0, 1, 2, 3],
    [1, 3],
    [1, 2],
]);

Meta