EDU.auburn.VGJ.graph
Class Graph

java.lang.Object
  |
  +--EDU.auburn.VGJ.graph.Graph
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
BiconnectGraph, Model

public class Graph
extends java.lang.Object
implements java.lang.Cloneable

A class for representing a graph abstractly.

Here is the source.

Author:
Larry Barowski, Dennis Wagelaar

Field Summary
protected  java.util.Hashtable edges_
          edges_ stores all edges in the graph.
protected  java.util.Hashtable idHash_
          idHash_ is a lookup table for node ids.
protected  int lastTopId_
          lastTopId_ holds the next available id for a node.
protected  NodeList nodeList_
          nodeList_ holds the graph.
 
Constructor Summary
Graph()
          construct empty graph
Graph(boolean yesorno)
          construct empty graph with direction
Graph(GMLobject gml)
           
 
Method Summary
 Set children(int n)
           
 java.lang.Object clone()
          makes a copy of the current graph
 void copy(Graph newgraph)
          Copy the properties of another graph.
 void dummysToEdgePaths()
          Convert dummy nodes to edge paths.
 int firstAvailable()
           
 Node firstNode()
           
 int firstNodeIndex()
           
 Edge getEdge(int n1, int n2)
           
 DPoint3[] getEdgePathPoints(int n1, int n2)
          Get the path points for an edge.
 java.util.Enumeration getEdges()
           
 int getIndexFromNode(Node node)
           
 Node getNodeFromId(int id)
           
 Node getNodeFromIndex(int index)
           
 void group(Node node, boolean state)
           
 int highestIndex()
           
 void insertEdge(Edge edge)
          Insert an edge.
 void insertEdge(int n1, int n2)
          insert an edge between two nodes
 void insertEdge(int n1, int n2, DPoint3[] points)
          Insert an edge with path points.
 void insertEdge(int n1, int n2, DPoint3[] points, java.lang.String label)
          Insert an edge with path points and a label.
 int insertNode()
          insert new node into graph; no initial connections
 int insertNode(boolean dummy)
          Insert new node or dummy node into the graph.
 void insertNodeAt(int index)
          insert new node into graph; into the nodelist at the index
 boolean isDirected()
          function to determine the graph type (directed or undirected)
 void killGroup(Node node)
           
 Node nextNode(Node node)
           
 int nextNodeIndex(int index)
           
 Node nodeFromIndex(int index)
           
 int numberOfNodes()
           
 void pack()
          Re-index so the indexes go from 0 to number of nodes - 1.
 Set parents(int n)
           
 void removeEdge(Edge edge)
           
 void removeEdge(int n1, int n2)
          remove the connection from n1 to n2 but leave the nodes in place
 void removeEdgePaths()
          Eliminate edge paths.
 void removeGroups()
           
 void removeNode(int n)
          remove the node from the graph(also removes the edges connected to it)
 void removeNode(Node nin)
          remove the node from the graph
 void setDirected(boolean directed)
           
 void setGMLvalues(GMLobject gml)
          Set the GML values of a GML object to those of this Graph.
 void setNodeGroup(Node node, Node groupnode)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nodeList_

protected NodeList nodeList_
nodeList_ holds the graph. Was private, made protected by Dennis Wagelaar.

idHash_

protected java.util.Hashtable idHash_
idHash_ is a lookup table for node ids. Was private, made protected by Dennis Wagelaar.

lastTopId_

protected int lastTopId_
lastTopId_ holds the next available id for a node. Was private, made protected by Dennis Wagelaar.

edges_

protected java.util.Hashtable edges_
edges_ stores all edges in the graph. Was private, made public by Dennis Wagelaar.
Constructor Detail

Graph

public Graph()
construct empty graph

Graph

public Graph(boolean yesorno)
construct empty graph with direction

Graph

public Graph(GMLobject gml)
Method Detail

setGMLvalues

public void setGMLvalues(GMLobject gml)
Set the GML values of a GML object to those of this Graph.

isDirected

public boolean isDirected()
function to determine the graph type (directed or undirected)
Returns:
boolean value

clone

public java.lang.Object clone()
makes a copy of the current graph
Overrides:
clone in class java.lang.Object
Returns:
copy of current graph

copy

public void copy(Graph newgraph)
Copy the properties of another graph. This assumes the other graph will be subsequently deleted - otherwise use copy(clone(graph_to_copy)).

insertNode

public int insertNode()
insert new node into graph; no initial connections
Returns:
index of the new node

insertNode

public int insertNode(boolean dummy)
Insert new node or dummy node into the graph.
Returns:
index of the new node

getNodeFromIndex

public Node getNodeFromIndex(int index)
Returns:
the node at the 'index'

getNodeFromId

public Node getNodeFromId(int id)

insertNodeAt

public void insertNodeAt(int index)
                  throws java.io.IOException
insert new node into graph; into the nodelist at the index
Parameters:
integer - index to place node
Returns:
nodeList_ with the new node

removeNode

public void removeNode(int n)
remove the node from the graph(also removes the edges connected to it)

removeNode

public void removeNode(Node nin)
remove the node from the graph

insertEdge

public void insertEdge(int n1,
                       int n2)
insert an edge between two nodes
Parameters:
two - integers node indexes

insertEdge

public void insertEdge(int n1,
                       int n2,
                       DPoint3[] points)
Insert an edge with path points.

insertEdge

public void insertEdge(int n1,
                       int n2,
                       DPoint3[] points,
                       java.lang.String label)
Insert an edge with path points and a label.

insertEdge

public void insertEdge(Edge edge)
Insert an edge.

getEdgePathPoints

public DPoint3[] getEdgePathPoints(int n1,
                                   int n2)
Get the path points for an edge.

getEdge

public Edge getEdge(int n1,
                    int n2)

removeEdge

public void removeEdge(int n1,
                       int n2)
remove the connection from n1 to n2 but leave the nodes in place
Parameters:
integer - index of each node on the edge

removeEdge

public void removeEdge(Edge edge)

parents

public Set parents(int n)
Parameters:
node - to get parents of
Returns:
a set of all the nodes leading to n

children

public Set children(int n)
Returns:
a set of all the nodes n leads to

numberOfNodes

public int numberOfNodes()
Returns:
the number of nodes in the graph

firstNode

public Node firstNode()
Returns:
the first node of the graph

nextNode

public Node nextNode(Node node)
Returns:
the next node after node

getIndexFromNode

public int getIndexFromNode(Node node)
Returns:
the integer value of the index for the node

firstNodeIndex

public int firstNodeIndex()
Returns:
the index of the first node in graph.nodeList

nextNodeIndex

public int nextNodeIndex(int index)
Returns:
the index of the next node after the current index

firstAvailable

public int firstAvailable()

highestIndex

public int highestIndex()

setDirected

public void setDirected(boolean directed)

pack

public void pack()
Re-index so the indexes go from 0 to number of nodes - 1.

removeEdgePaths

public void removeEdgePaths()
Eliminate edge paths.

dummysToEdgePaths

public void dummysToEdgePaths()
Convert dummy nodes to edge paths.

getEdges

public java.util.Enumeration getEdges()

nodeFromIndex

public Node nodeFromIndex(int index)

group

public void group(Node node,
                  boolean state)

killGroup

public void killGroup(Node node)

setNodeGroup

public void setNodeGroup(Node node,
                         Node groupnode)

removeGroups

public void removeGroups()