edu.stanford.multiagent.gamer.graphs
Class ALGraph

java.lang.Object
  |
  +--edu.stanford.multiagent.gamer.ParameterizedObject
        |
        +--edu.stanford.multiagent.gamer.graphs.Graph
              |
              +--edu.stanford.multiagent.gamer.graphs.ALGraph
Direct Known Subclasses:
BAGraph, CompleteGraph, NAryTree, NDimensionalGrid, PLODGraph, RandomGraph, RingGraph, RoadGraph, SmallWorldGraph, StarGraph

public abstract class ALGraph
extends Graph

An Adjacency list implementation of the Graph interface.


Field Summary
protected  java.util.Vector nodes
           
 
Fields inherited from class edu.stanford.multiagent.gamer.graphs.Graph
nEdges, nNodes, nodeData, pReflexEdges, pSymEdges
 
Fields inherited from class edu.stanford.multiagent.gamer.ParameterizedObject
parameters
 
Constructor Summary
ALGraph()
          Constructor
ALGraph(int nNodes)
          Constructor which initializes the number of nodes.
 
Method Summary
 void addEdge(int s, int t)
          Add a new edge to the graph.
 void addEdge(int s, int t, java.lang.Object data)
          Add an edge with data to the graph.
 void addNode()
          Adds a new node to the graph.
 boolean areNeighbours(int from, int to)
          Checks if two nodes are neighbours in the graph.
protected  void checkParameters()
          May be implemented by subclasses to check parameters if any exist.
 edu.stanford.multiagent.gamer.graphs.Edge getEdge(int s, int t)
          Returns an Edge object from the graph.
 java.util.Iterator getEdges(int from)
          Returns an iterator over the outgoing edges from a node.
 java.util.Iterator getNeighbours(int from)
          Returns an iterator over the node's neighbours.
 int getNumNeighbours(int from)
          Return number of neighbours extending from a node.
 void removeEdge(edu.stanford.multiagent.gamer.graphs.Edge e)
          Removes an edge from the graph.
 void removeEdge(int s, int t)
          Removes an edge from the graph.
 void setEdgeData(int s, int t, java.lang.Object data)
          Sets the data item for a preexisting edge.
 
Methods inherited from class edu.stanford.multiagent.gamer.graphs.Graph
getGraphHelp, getHelp, getNEdges, getNNodes, getNodeData, hasSymEdges, initialize, reflexEdgesOk, setNodeData
 
Methods inherited from class edu.stanford.multiagent.gamer.ParameterizedObject
doGenerate, getBooleanParameter, getDescription, getDoubleParameter, getLongParameter, getParamDescription, getParameter, getParameters, getStringParameter, randomizeParameters, setParameter, setParameter, setParameters, setParameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nodes

protected java.util.Vector nodes
Constructor Detail

ALGraph

public ALGraph()
        throws java.lang.Exception
Constructor


ALGraph

public ALGraph(int nNodes)
        throws java.lang.Exception
Constructor which initializes the number of nodes.

Parameters:
nNodes - the number of nodes in the graph
Method Detail

addNode

public void addNode()
Adds a new node to the graph.

Specified by:
addNode in class Graph

addEdge

public void addEdge(int s,
                    int t)
Add a new edge to the graph.

Specified by:
addEdge in class Graph
Parameters:
s - the index of the node where the edge should start
t - the index of the node where the edge should end

addEdge

public void addEdge(int s,
                    int t,
                    java.lang.Object data)
Add an edge with data to the graph.

Specified by:
addEdge in class Graph
Parameters:
s - the index of the node where the edge should start
t - the index of the node where the graph should end
data - the data which is to be stored at the edge

setEdgeData

public void setEdgeData(int s,
                        int t,
                        java.lang.Object data)
Sets the data item for a preexisting edge.

Specified by:
setEdgeData in class Graph
Parameters:
s - the index of the node where the edge begins
t - the index of the node where the edge ends
data - the data which is to be stored at the edge

removeEdge

public void removeEdge(int s,
                       int t)
Removes an edge from the graph.

Specified by:
removeEdge in class Graph
Parameters:
s - the index of the node where the edge begins
t - the index of the node where the edge ends

removeEdge

public void removeEdge(edu.stanford.multiagent.gamer.graphs.Edge e)
Removes an edge from the graph.

Specified by:
removeEdge in class Graph
Parameters:
e - the edge to be removed

getEdge

public edu.stanford.multiagent.gamer.graphs.Edge getEdge(int s,
                                                         int t)
Returns an Edge object from the graph.

Specified by:
getEdge in class Graph
Parameters:
s - the index of the node where the edge begins
t - the index of the node where the edge ends

areNeighbours

public boolean areNeighbours(int from,
                             int to)
Checks if two nodes are neighbours in the graph. Note that direction matters in this check.

Specified by:
areNeighbours in class Graph
Parameters:
from - the index of the node where the edge begins
to - the index of the node where the edge ends

getNeighbours

public java.util.Iterator getNeighbours(int from)
Returns an iterator over the node's neighbours.

Specified by:
getNeighbours in class Graph
Parameters:
from - the index of the node whose neighbours should be returned

getEdges

public java.util.Iterator getEdges(int from)
Returns an iterator over the outgoing edges from a node.

Specified by:
getEdges in class Graph
Parameters:
from - the index of the node whose neighbours should be returned

getNumNeighbours

public int getNumNeighbours(int from)
Return number of neighbours extending from a node.

Parameters:
from - the index of the node

checkParameters

protected void checkParameters()
                        throws java.lang.Exception
May be implemented by subclasses to check parameters if any exist.

Specified by:
checkParameters in class ParameterizedObject
Throws:
java.lang.Exception - if anything is wrong with the parameter values