Native File Format for Graphs
The native file format for graphs consists of several lines which are
separated by endl . Comment-lines have a # character
in the first column and are ignored. The output can be partitioned in
three sections:
Header Section
The first line always contains the string LEDA.GRAPH . If
the graph type is not parameterized, i.e. graph,
the following two lines both contain the string void . In
case the graph is parameterized, i.e. GRAPH ,
these lines contain a description of the node type and the edge type. The fourth
line specifies if the graph is either directed (-1) or undirected (-2).
Nodes Section
The first line contains n , the number of nodes in the graph.
The nodes are ordered and numbered according to their position in the
node list of the graph. Each of the following n lines contains
the information which is associated with the respective node of the graph.
When the information of a node (or an edge) is sent to an output stream,
it is always enclosed by the strings |{ and }| .
If the graph is not parameterized, then the string between these parantheses
is empty, so that all the n lines contain the string |{}| .
Edges Section
The first line contains m , the number of edges in the graph.
The edges of the graph are ordered by two criteria: first according to
the number of their source node and second according to their position
in the adjacency list of the source node. Each of the next m
lines contains the description of an edge which consists of four space-separated
parts:
- the number of the source node
- the number of the target node
- the number of the reversal edge or 0, if no such edge is set
- the information associated with the edge (cf. nodes section)
Note: For the data type planar_map
the order of the edges is important, because the ordering of the edges
in the adjacency list of a node corresponds to the counter-clockwise ordering
of these edges around the node in the planar embedding. And the information
about reversal edges is also vital for this data type.
Example of a Graph
The following lines show a graph in native file format. It consists of
five nodes and seven edges. The nodes have a parameter of type string
and the edges have a parameter of type int.
#header section
LEDA.GRAPH
string
int
-1
#nodes section
5
|{v1}|
|{v2}|
|{v3}|
|{v4}|
|{v5}|
#edges section
7
1 2 0 |{4}|
1 3 0 |{3}|
2 3 0 |{2}|
3 4 0 |{3}|
3 5 0 |{7}|
4 5 0 |{6}|
5 1 0 |{1}|
Example of how to
use GML format and native graph file format
Strength
Disadvantage
Tips
- Use the native format if you need to store a LEDA graph or GraphWin
|