Class AbstractGraph

java.lang.Object
  |
  +--AbstractGraph
All Implemented Interfaces:
java.lang.Cloneable, Graph
Direct Known Subclasses:
AbstractYutsis

public abstract class AbstractGraph
extends java.lang.Object
implements Graph

This abstract class provides a skeleton implementation of the Graph interface to minimize the effort to implement this interface.

Author:
Dries.VanDyck@rug.ac.be
See Also:
Graph, NodeIterator

Constructor Summary
AbstractGraph()
           
 
Method Summary
 void addChangeListener(javax.swing.event.ChangeListener l)
          Adds a ChangeListener to the Graph to be notified of structural changes.
 java.lang.Object clone()
          Returns an exact copy of the object.
 boolean connected(int i, int j)
          True if nodes i and j are connected, false otherwise.
protected  void fireStateChanged()
          Send a ChangeEvent, whose source is this Graph, to each listener.
 java.lang.String[] gmlEdgeLabels(int i)
          Returns the edge labels of node i to be used for saving the Graph in GML-format; this is a default implementation returning null, indicating that no edge label is used.
 boolean isTree(int[] nodeset)
          Checks of the nodes in the nodeset form a vertex induced tree.
 void removeChangeListener(javax.swing.event.ChangeListener l)
          Removes the ChangeListener l from the Graph.
 void toGml(java.io.PrintStream out)
          Prints the graph in its current state to the PrintStream in gml-format (graphlet).
 java.lang.String toString()
          Returns a string representation of the graph in adjacencylist format:
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface Graph
first, isRemoved, last, neighbors, nodeIterator, nrOfEdges, nrOfNodes, order
 

Constructor Detail

AbstractGraph

public AbstractGraph()
Method Detail

connected

public boolean connected(int i,
                         int j)
True if nodes i and j are connected, false otherwise.

Specified by:
connected in interface Graph
Parameters:
i - a node of the Graph
j - a node of the Graph
Returns:
true if i and j are connected, false otherwise

addChangeListener

public void addChangeListener(javax.swing.event.ChangeListener l)
Adds a ChangeListener to the Graph to be notified of structural changes.

Specified by:
addChangeListener in interface Graph
Parameters:
l - the ChangeListener to be added

removeChangeListener

public void removeChangeListener(javax.swing.event.ChangeListener l)
Removes the ChangeListener l from the Graph.

Specified by:
removeChangeListener in interface Graph
Parameters:
l - the ChangeListener to be removed

fireStateChanged

protected void fireStateChanged()
Send a ChangeEvent, whose source is this Graph, to each listener.


isTree

public boolean isTree(int[] nodeset)
Checks of the nodes in the nodeset form a vertex induced tree. Returns also false when the nodeset is not connected or one of the specified nodes is removed.

Specified by:
isTree in interface Graph
Parameters:
nodeset - the nodes to be checked if they induce a tree
Returns:
true, if the specified nodeset induces a tree, false otherwise

toString

public java.lang.String toString()
Returns a string representation of the graph in adjacencylist format:
 0: nghb1 nghb2 nghb3
 ... 
 i: nghbi1 nghbi2 nghbi3
 ... 

Overrides:
toString in class java.lang.Object
Returns:
a String representation of this CubicGraph

clone

public java.lang.Object clone()
Returns an exact copy of the object.

Overrides:
clone in class java.lang.Object
Returns:
a clone of this object

toGml

public void toGml(java.io.PrintStream out)
Prints the graph in its current state to the PrintStream in gml-format (graphlet).

Specified by:
toGml in interface Graph
Parameters:
out - the PrintStream to which output will be written.

gmlEdgeLabels

public java.lang.String[] gmlEdgeLabels(int i)
Returns the edge labels of node i to be used for saving the Graph in GML-format; this is a default implementation returning null, indicating that no edge label is used.

Parameters:
i - node of which the edge labels must be returned
Returns:
a array of edge labels of node i in the same order the neighbors are returned.