bcds.phison.io
Class NetGraphReader<V extends GraphIONode,E>

java.lang.Object
  extended by bcds.phison.io.GraphReader<V,E>
      extended by bcds.phison.io.SgfGraphReader<V,E>
          extended by bcds.phison.io.NetGraphReader<V,E>

public class NetGraphReader<V extends GraphIONode,E>
extends SgfGraphReader<V,E>

Reads a topology file in .net format. The following example illustrates the overall structure of a .net file:

  [netname]
  somename    # Purely informational. It is never used.

  [nodenum]
  # Number of nodes. Three, in this example.
  3

  [coordinates]  # This section lists the nodes.
  # xcoord ycoord label
  0.0   0.0  London
  1.5  -3.5  Madrid
  -2.1  4.7  Paris

  [capacity]     # Defines the adjacency matrix and link capacity.
  # This defines a "ring" among the three nodes.
  0  10 20
  10  0 5
  20  5 0

  [cost]         # For example, physical distance in km.
  0  1200 180
  1200  0 800
  180  800 0

  [traffic]      # In this example, only nodes 0-1 and 1-2 have entries.
  0 30 0 # 0
  30 0 10 # 1
  0 10 0 # 2
 
The order of the sections is irrelevant, but it is recommended that [nodenum] appears as soon as possible (that section needs to be read before the rest, which opens the possiblity for multiple passes over the whole file).

Other considerations:

This format is appropriate for small topologies. It is impractical when the number of nodes is large because of the matrix representation used. Sometimes, however, it is necessary to export the topology as an adjacency matrix (for example for reading it with MATLAB). In such a case, you can use this format and copy-and-paste the [capacity] section.

The .net and .sgf file formats have many features in common. More information on the .sgf format can be found here.

Author:
Juan Segovia S.

Constructor Summary
NetGraphReader(java.lang.String fname, SimGraph<V,E> g)
          Creates a NetGraphReader so that a later call to run() will populate the graph g from the file named fname.
 
Method Summary
 void run()
          Reads the file and populates the SimGraph g and the maps corresponding to edge or node pair attributes.
 
Methods inherited from class bcds.phison.io.GraphReader
getIdToNodeMap, getNode, markEdgeAttr, markNodePairAttr, raiseBadFormatEx, setInputStream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NetGraphReader

public NetGraphReader(java.lang.String fname,
                      SimGraph<V,E> g)
Creates a NetGraphReader so that a later call to run() will populate the graph g from the file named fname.

Beware that this class cannot read from "-" (that is, stdin/System.in) because rewind is necessary to make multiple passes on the file, and stdin does not support that operation.

Throws:
AnyException - wrappin an IOException if opening fname for reading fails for any reason.
Method Detail

run

public void run()
Reads the file and populates the SimGraph g and the maps corresponding to edge or node pair attributes.

Overrides:
run in class SgfGraphReader<V extends GraphIONode,E>