Class CommGraph

java.lang.Object
  extended by CommGraph

public class CommGraph
extends java.lang.Object

Stores the topology of an instantaneous communication graph, as well as the message queues between each pair of robots connected in the graph. Can be used to hold directed and undirected edges. Edge addition functions copy message queues from prior graph, if one is provided.

Graph representation is in the form of two adjacency lists (see http://www.nist.gov/dads/HTML/adjacencyListRep.html for documentation on adjacency lists) (also see Cormen, Leierson, Rivest, Stein Chapter 22) One adjacency list is for quick lookup for all edges incoming to a particular node, the other is for all edges outgoing to a particular node. The two structures edge share representation memory for each shared edge.

Since:
1.0

Constructor Summary
CommGraph()
           
CommGraph(CommGraph src)
          Copy constructor -- performs deep copy of graph
CommGraph(int nNumNodes)
          Creates an empty graph (no edges) on nNumNodes nodes
 
Method Summary
 CommLink addLink(int iSrc, int iDst, CommGraph gCopyLinksFrom)
          Adds a new link (directed edge) to a graph.
 CommLink addLink(int iSrc, int iDst, CommLink.IChannelData channelData, CommGraph gCopyLinksFrom)
          Adds a new link (directed edge) to a graph.
 IMsgChannel getChannelType()
           
 java.util.Iterator<CommLink> getEdgesFrom(int nNodeFrom)
           
 java.util.Iterator<CommLink> getEdgesTo(int nNodeTo)
           
 int getSize()
           
 void insertExistLink(CommLink link)
          Insert an exsting CommLink into this graph.
 void setChannelType(IMsgChannel channelToClone)
          Changes the default channel type for new links new channels are all of the same type as channelToClone
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommGraph

public CommGraph()

CommGraph

public CommGraph(int nNumNodes)
Creates an empty graph (no edges) on nNumNodes nodes


CommGraph

public CommGraph(CommGraph src)
Copy constructor -- performs deep copy of graph

Method Detail

setChannelType

public void setChannelType(IMsgChannel channelToClone)
Changes the default channel type for new links new channels are all of the same type as channelToClone


getChannelType

public IMsgChannel getChannelType()

getEdgesFrom

public java.util.Iterator<CommLink> getEdgesFrom(int nNodeFrom)
Parameters:
nNodeFrom - node to get outgoing edges of
Returns:
iterator for list of outgoing edges of nNodeFrom Each iterator element should be cast to type CommLink.

getEdgesTo

public java.util.Iterator<CommLink> getEdgesTo(int nNodeTo)
Parameters:
nNodeTo - node to get incoming edges of
Returns:
iterator for list of incoming edges of nNodeTo Each iterator element should be cast to type CommLink.

insertExistLink

public void insertExistLink(CommLink link)
Insert an exsting CommLink into this graph.

Parameters:
link - link to insert

addLink

public CommLink addLink(int iSrc,
                        int iDst,
                        CommGraph gCopyLinksFrom)
Adds a new link (directed edge) to a graph. Copies channel from previous state communication graph if available

Parameters:
iSrc - source index of link to add
iDst - destination index of link to add
gCopyLinksFrom - previous graph (to copy communication channels from if available) Can be null.
Returns:
newly created link

addLink

public CommLink addLink(int iSrc,
                        int iDst,
                        CommLink.IChannelData channelData,
                        CommGraph gCopyLinksFrom)
Adds a new link (directed edge) to a graph. Copies channel from previous state communication graph if available

Parameters:
iSrc - source index of link to add
iDst - destination index of link to add
channelData - associated channel data
gCopyLinksFrom - previous graph (to copy communication channels from if available) Can be null.
Returns:
newly created link

getSize

public int getSize()
Returns:
Number of nodes in graph