util.graph
Class Graph

java.lang.Object
  |
  +--util.graph.Graph
All Implemented Interfaces:
Cloneable, Serializable
Direct Known Subclasses:
SignalGraph

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.

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 addEdge(Object from, String outPort, Object to, String inPort)
           
 util.graph.Node findNode(Object contents)
          Find a node given its contents.
 Vector getEdges()
          Returns all edges
 Vector getEdgesFrom(Object node)
          Get all edges leaving a particular node
 Vector getNodes()
          Returns all the nodes.
 Vector getNonSources()
           
 Path getPath(Object fromObj, Object toObj)
          Get the cheapest path going from from to to.
 Vector getSinkNodes()
          Returns all nodes that do not have any edges going out of them (so it may return nodes that have no nodes going into them either)
 Vector getSinks()
           
 Vector getSourceNodes()
          Returns all nodes that do not have any edges going into them (so it may return nodes that have no nodes going out of them either)
 Vector getSources()
           
 Edge makeEdge(Object from, String outPort, Object to, String inPort)
          Override this if you want fancy-style edges.
protected  Path makePath(util.graph.Node start)
          Override this if you want fancy-style paths.
 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.
 
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

findNode

public util.graph.Node findNode(Object contents)
Find a node given its contents.

makePath

protected Path makePath(util.graph.Node start)
Override this if you want fancy-style paths.

makeEdge

public Edge makeEdge(Object from,
                     String outPort,
                     Object to,
                     String inPort)
Override this if you want fancy-style 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.

addEdge

public void addEdge(Object from,
                    String outPort,
                    Object to,
                    String inPort)

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.

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

getSourceNodes

public Vector getSourceNodes()
Returns all nodes that do not have any edges going into them (so it may return nodes that have no nodes going out of them either)

getSources

public Vector getSources()

getSinks

public Vector getSinks()

getNonSources

public Vector getNonSources()

getSinkNodes

public Vector getSinkNodes()
Returns all nodes that do not have any edges going out of them (so it may return nodes that have no nodes going into them either)