Next Previous Contents

4.6 Class StreamARGLoader<Node,Edge>

Defined in: argloader.h

Extends: ARGEdit

Overview: This class allows to read (or write) an attributed graph from a text stream. The class relies on the stream insertion/extraction operators (<lt; and >>) to perform the input/output operations on the attributes.

The class parameters (Node and Edge) are the types of the node/edge attributes, which are stored internally through pointers. The attributes can be heap allocated, or a more efficient allocation strategy can be implemented by means of an Allocator object.

File format

On the first line there must be the number of nodes; subsequent lines will contain the node attributes, one node per line, preceded by the node id; node ids must be in the range from 0 to the number of nodes - 1. Then, for each node there is the number of edges coming out of the node, followed by a line for each edge containing the ids of the edge ends and the edge attribute. Blank lines, and lines starting with #, are ignored. An example file, where both node and edge attributes are ints, could be the following:


     # Number of nodes
     3
     # Node attributes
     0 27
     1 42
     2 13
           
     # Edges coming out of node 0
     2
     0 1  24
     0 2  73
 
     # Edges coming out of node 1
     1
     1 3  66
 
     # Edges coming out of node 2
     0      


Next Previous Contents