Class Network

java.lang.Object
  extended by org.jgrapht.graph.AbstractGraph<V,E>
      extended by org.jgrapht.graph.AbstractBaseGraph<V,E>
          extended by org.jgrapht.graph.SimpleGraph<Node,org.jgrapht.graph.DefaultEdge>
              extended by Network
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, org.jgrapht.Graph<Node,org.jgrapht.graph.DefaultEdge>, org.jgrapht.UndirectedGraph<Node,org.jgrapht.graph.DefaultEdge>

public class Network
extends org.jgrapht.graph.SimpleGraph<Node,org.jgrapht.graph.DefaultEdge>

Class representing an entire network.

See Also:
Serialized Form

Constructor Summary
Network(int nnodes, int nedges, org.jgrapht.VertexFactory<Node> nodeFactory)
          Constructor leading to a randomly generated topology.
Network(java.lang.String graphFile, org.jgrapht.VertexFactory<Node> nodeFactory)
          Constructor that generates the Network using a description in a file.
 
Method Summary
 boolean failNode(int n)
          Mark a node as non-operational.
static Network getNetwork()
          There can be only one network in an application.
 Node[] getNodeArray()
           
 boolean hasChanged()
          Returns true if the network has changed (nodes added or deleted) since the last invocation of takeStep(), false otherwise.
 void initialize()
          This method MUST BE invoked after construction to finalize creation of the Network object.
 int numEdges()
           
 int numNodes()
           
 void takeStep()
          Take a time step.
 
Methods inherited from class org.jgrapht.graph.AbstractBaseGraph
addEdge, addEdge, addVertex, clone, containsEdge, containsVertex, degreeOf, edgeSet, edgesOf, getAllEdges, getEdge, getEdgeFactory, getEdgeSource, getEdgeTarget, getEdgeWeight, incomingEdgesOf, inDegreeOf, isAllowingLoops, isAllowingMultipleEdges, outDegreeOf, outgoingEdgesOf, removeEdge, removeEdge, removeVertex, setEdgeSetFactory, setEdgeWeight, vertexSet
 
Methods inherited from class org.jgrapht.graph.AbstractGraph
assertVertexExist, containsEdge, removeAllEdges, removeAllEdges, removeAllEdges, removeAllVertices, toString, toStringFromSets
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jgrapht.UndirectedGraph
degreeOf
 
Methods inherited from interface org.jgrapht.Graph
addEdge, addEdge, addVertex, containsEdge, containsEdge, containsVertex, edgeSet, edgesOf, getAllEdges, getEdge, getEdgeFactory, getEdgeSource, getEdgeTarget, getEdgeWeight, removeAllEdges, removeAllEdges, removeAllVertices, removeEdge, removeEdge, removeVertex, vertexSet
 

Constructor Detail

Network

public Network(int nnodes,
               int nedges,
               org.jgrapht.VertexFactory<Node> nodeFactory)
        throws java.lang.IllegalArgumentException,
               java.lang.IllegalStateException
Constructor leading to a randomly generated topology. First construct the network object, then call initialize().

There can be at most one Network object in the application. An IllegalStateException is thrown otherwise.

Throws:
java.lang.IllegalArgumentException
java.lang.IllegalStateException

Network

public Network(java.lang.String graphFile,
               org.jgrapht.VertexFactory<Node> nodeFactory)
        throws java.lang.IllegalStateException,
               java.io.FileNotFoundException,
               java.io.IOException
Constructor that generates the Network using a description in a file. The file format is the number of nodes (as an integer) on the first line, followed by edges given as source/destination node numbers (nodes are numbered 0, 1, ... , #nodes-1):
   #nodes
   src dst
   src dst
   ...
 

First construct the network object, then call initialize().

There can be at most one Network object in the application. An IllegalStateException is thrown otherwise.

Throws:
java.lang.IllegalStateException
java.io.FileNotFoundException
java.io.IOException
Method Detail

getNetwork

public static Network getNetwork()
There can be only one network in an application. There is a static accessor function to find it.


getNodeArray

public Node[] getNodeArray()

numNodes

public int numNodes()

numEdges

public int numEdges()

hasChanged

public boolean hasChanged()
Returns true if the network has changed (nodes added or deleted) since the last invocation of takeStep(), false otherwise.


initialize

public void initialize()
This method MUST BE invoked after construction to finalize creation of the Network object. (For reasons of implementation detail what is done here cannot be done in the constructors.)


failNode

public boolean failNode(int n)
Mark a node as non-operational. The node is removed from the SimpleGraph that the Network object is.
Returns prior failed status of node (i.e., true if it was already failed).


takeStep

public void takeStep()
Take a time step. Go throught nodes in a random order, and invoke each node's update routine with only some fixed probability.