util.graph
Class Graph

java.lang.Object
  |
  +--util.graph.Graph
Direct Known Subclasses:
PermGraph

public class Graph
extends Object
implements Serializable, Cloneable

Inspired by Gajos's vision of the future, I, a humble and order-following code-monkey named Luke Weisman, have written this Graph class. This class allows for looking for least-cost paths where paths are 'owned' by objects. an object can only own ONE path at a time.

See Also:
Serialized Form

Field Summary
protected  Vector edges
           
protected  Vector nodes
           
 
Constructor Summary
Graph()
           
 
Method Summary
 void addEdge(Edge e)
          Add an edge to the graph.
 void changeNode(Object fromN, Object n)
          Replace a node with another node--all edges will be updated.
 void commitPath(Path path, Object owner, int cost)
          Commit a path to the graph, with the given cost and owner.
 Vector getEdges()
          Returns all edges
 Vector getEdgesFrom(Object node)
          Get all edges leaving a particular node
 Vector getNodes()
          Returns all the nodes.
 Path getPath(Object fromObj, Object toObj)
          Get the cheapest path going from from to to.
 void removeEdge(Edge e)
          Remove edge from graph.
 void removeEdges(Collection c)
          Remove all edges in collection from the graph.
 void removeNode(Object n)
          Remove a node, and all edges associated with that node.
 void removeOwner(Object owner)
          Remove owner from graph edges.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

edges

protected Vector edges

nodes

protected Vector nodes
Constructor Detail

Graph

public Graph()
Method Detail

removeOwner

public void removeOwner(Object owner)
Remove owner from graph edges.

getPath

public Path getPath(Object fromObj,
                    Object toObj)
Get the cheapest path going from from to to. Does not commit path, just returns it.

commitPath

public void commitPath(Path path,
                       Object owner,
                       int cost)
Commit a path to the graph, with the given cost and owner.

addEdge

public void addEdge(Edge e)
Add an edge to the graph.

removeEdge

public void removeEdge(Edge e)
Remove edge from graph.

removeEdges

public void removeEdges(Collection c)
Remove all edges in collection from the graph.

removeNode

public void removeNode(Object n)
Remove a node, and all edges associated with that node.

changeNode

public void changeNode(Object fromN,
                       Object n)
Replace a node with another node--all edges will be updated.

getNodes

public Vector getNodes()
Returns all the nodes. (The Objects, not the Node class)

getEdges

public Vector getEdges()
Returns all edges

getEdgesFrom

public Vector getEdgesFrom(Object node)
Get all edges leaving a particular node