nz.ac.waikato.mcennis.rat.graph
Class GraphIndex

java.lang.Object
  extended by nz.ac.waikato.mcennis.rat.graph.GraphIndex

public class GraphIndex
extends java.lang.Object

Helper Class that maintains an inverse index - the set of all graphs that an actor belongs to. This is used to facilitate algorithms that change behavior depending on membership in groups.


Constructor Summary
GraphIndex()
           
 
Method Summary
 void addActor(Actor a, Graph g)
          Add a reference between a graph and an actor.
 void addGraph(Graph g)
          Adds a graph reference to the object
 Graph[] getGraph(Actor a)
          Return an array of all graphs that contain the actor or null if no indexed graph contains the actor.
 Graph getGraph(java.lang.String s)
          Returns the graph with the given ID or null if no graph with this ID is indexed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GraphIndex

public GraphIndex()
Method Detail

addActor

public void addActor(Actor a,
                     Graph g)
Add a reference between a graph and an actor. Implicitly adds the graph as well if it is not already in the index.

Parameters:
a - actor reference
g - graph reference

addGraph

public void addGraph(Graph g)
Adds a graph reference to the object

Parameters:
g - graph to be added

getGraph

public Graph[] getGraph(Actor a)
Return an array of all graphs that contain the actor or null if no indexed graph contains the actor.

Parameters:
a - actor to be checked
Returns:
array of graphs containing the actor

getGraph

public Graph getGraph(java.lang.String s)
Returns the graph with the given ID or null if no graph with this ID is indexed.

Parameters:
s - ID to retrieve graphs from
Returns:
Graph with the unique ID s