Report a bug
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using a local clone.

mir.graph

Basic routines to work with graphs.
Authors:
Ilya Yaroshenko
template GraphIterator(I = uint, J = size_t)
template Graph(I = uint, J = size_t)
template GraphSeries(T, I = uint, J = size_t)
template RCGraphIterator(I = uint, J = size_t)
template RCGraph(I = uint, J = size_t)
template RCGraphSeries(T, I = uint, J = size_t)
GraphSeries!(T, I, J) graphSeries(I = uint, J = size_t, T, Range)(in Range[T] aaGraph);
Parameters:
 Range[T] aaGraph graph that is represented as associative array
Returns:
A graph series composed of keys (sorted .index) and arrays of indeces (.data)

Complexity O(log(V) (V + E))

Examples:
auto gs = [
"b" : ["a"],
"a" : ["b", "c"],
"c" : ["b"],
].graphSeries;

assert (gs.index == ["a", "b", "c"]); // sorted
assert (gs.data == [
[1, 2], // a
,    // b
,    // c
]);
RCGraph!(I, J) rcgraph(I = uint, J = size_t, KeyIterator, RangeIterator)(Series!(KeyIterator, RangeIterator) graph);
Parameters:
 Series!(KeyIterator, RangeIterator) graph graph that is represented a series
Returns:
A graph as an arrays of indeces

Complexity O(log(V) (V + E))

Examples:
import mir.series: series;

static immutable keys = ["a", "b", "c"];
static immutable data = [
["b", "c"],
["a"],
["b"],
];

static immutable graphValue = [
[1, 2], // a
,    // b
,    // c
];

assert (series(keys, data).rcgraph == graphValue);