Loads and saves graphs which are stored in a very simple format.
The first line must contain two numbers (the count of nodes and arcs). Each additional line must contain a pair of numbers for each arc (that is, the identifiers of the start and end nodes of the arc).
Optionally, arc functions (extensions) can be defined as excess tokens after the arc definition. Extensions are separated by whitespaces and thus must be nonempty strings containing no whitespaces.
The following example describes a path on 4 nodes, whose arcs each have a name and a cost associated to them. Node numbering starts from 1 here.
4 3
1 2 Arc1 0.2
2 3 Arc2 1.25
3 4 Arc3 0.33
The above example can be processed like this (provided that it is stored in c:\graph.txt
):
IGraph graph = loader.Graph;
Dictionary<Arc, string> arcNames = loader.Extensions[0];
Dictionary<Arc, double> arcCosts =
loader.Extensions[1].ToDictionary(kv => kv.Key, kv => double.Parse(kv.Value, CultureInfo.InvariantCulture));
Definition at line 63 of file IO.cs.