org.graffiti.graph
Class AdjListGraph

java.lang.Object
  extended by org.graffiti.attributes.AbstractAttributable
      extended by org.graffiti.graph.AbstractGraph
          extended by org.graffiti.graph.AdjListGraph
All Implemented Interfaces:
Attributable, DeepCopy, Graph
Direct Known Subclasses:
OptAdjListGraph

public class AdjListGraph
extends AbstractGraph
implements Graph

Implements the Graph-interface using an adjacency list representation of the graph. Requires AdjListNode and AdjListEdge as implementations for nodes and edges. Every method modifying the graph will inform the ListenerManager about the modification according to the description in Graph.

Version:
$Revision: 5779 $
See Also:
Graph, AbstractGraph, AdjListNode, AdjListEdge, AbstractNode, AbstractEdge

Constructor Summary
AdjListGraph()
          Constructs a new instance of an AdjListGraph.
AdjListGraph(CollectionAttribute coll)
          Constructs a new instance of an AdjListGraph.
AdjListGraph(Graph g, ListenerManager listenerManager)
          Constructs a new instance of an AdjListGraph from an instance of any Graph implementation.
AdjListGraph(Graph g, ListenerManager listenerManager, CollectionAttribute coll)
          Constructs a new instance of an AdjListGraph from an instance of any Graph implementation.
AdjListGraph(ListenerManager listenerManager)
          Constructs a new instance of an AdjListGraph.
AdjListGraph(ListenerManager listenerManager, CollectionAttribute coll)
          Constructs a new instance of an AdjListGraph.
 
Method Summary
 Object copy()
          Creates and returns a copy of the graph.
 Edge createEdge(Node source, Node target, boolean directed, CollectionAttribute col)
          Creates a new AdjListEdge that is in the current graph.
 Node createNode(CollectionAttribute col)
          Creates a new AdjListNode that is in the current graph.
 Iterator<Node> getNodesIterator()
          Returns an iterator over the nodes of the graph.
 boolean isModified()
          Indicates whether the Graph has been modified.
 void setModified(boolean modified)
          Should be set to False after saving changes and to True after making changes to the Graph.
 void setNodeFirst(Node node)
          The given node is moved to the front of the node list.
 void setNodeLast(Node node)
          The given node is moved to the end of the node list.
 
Methods inherited from class org.graffiti.graph.AbstractGraph
addAttributeConsumer, addEdge, addEdge, addEdgeCopy, addGraph, addNode, addNode, addNodeCopy, areConnected, clear, containsEdge, containsNode, deleteEdge, deleteNode, getAttTypesManager, getEdges, getEdges, getEdgesIterator, getGraphElements, getListenerManager, getNodes, getNumberOfDirectedEdges, getNumberOfEdges, getNumberOfNodes, getNumberOfUndirectedEdges, isDirected, isEmpty, isUndirected, removeAttributeConsumer, setDirected, setDirected
 
Methods inherited from class org.graffiti.attributes.AbstractAttributable
addAttribute, addBoolean, addByte, addDouble, addFloat, addInteger, addLong, addShort, addString, changeBoolean, changeByte, changeDouble, changeFloat, changeInteger, changeLong, changeShort, changeString, containsAttribute, getAttribute, getAttributes, getBoolean, getByte, getDouble, getFloat, getInteger, getLong, getShort, getString, removeAttribute, setBoolean, setByte, setDouble, setFloat, setInteger, setLong, setShort, setString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.graffiti.graph.Graph
addAttributeConsumer, addEdge, addEdge, addEdgeCopy, addGraph, addNode, addNode, addNodeCopy, clear, containsEdge, containsNode, deleteEdge, deleteNode, getAttTypesManager, getEdges, getEdges, getEdgesIterator, getGraphElements, getNodes, getNumberOfDirectedEdges, getNumberOfEdges, getNumberOfNodes, getNumberOfUndirectedEdges, isDirected, isEmpty, isUndirected, removeAttributeConsumer, setDirected, setDirected
 
Methods inherited from interface org.graffiti.attributes.Attributable
addAttribute, addBoolean, addByte, addDouble, addFloat, addInteger, addLong, addShort, addString, changeBoolean, changeByte, changeDouble, changeFloat, changeInteger, changeLong, changeShort, changeString, containsAttribute, getAttribute, getAttributes, getBoolean, getByte, getDouble, getFloat, getInteger, getListenerManager, getLong, getShort, getString, removeAttribute, setBoolean, setByte, setDouble, setFloat, setInteger, setLong, setShort, setString
 

Constructor Detail

AdjListGraph

public AdjListGraph()
Constructs a new instance of an AdjListGraph. Sets the ListenerManager of the new instance to the default ListenerManager.


AdjListGraph

public AdjListGraph(CollectionAttribute coll)
Constructs a new instance of an AdjListGraph. Sets the ListenerManager of the new instance to the default ListenerManager.

Parameters:
coll - the CollectionAttribute of the currently created AdjListGraph instance.

AdjListGraph

public AdjListGraph(ListenerManager listenerManager)
Constructs a new instance of an AdjListGraph. Sets the ListenerManager of the new instance to the specified one.

Parameters:
listenerManager - listener manager for the graph.

AdjListGraph

public AdjListGraph(ListenerManager listenerManager,
                    CollectionAttribute coll)
Constructs a new instance of an AdjListGraph. Sets the ListenerManager of the new instance to the specified one.

Parameters:
listenerManager - listener manager for the graph.
coll - the CollectionAttribute of the currently created AdjListGraph instance.

AdjListGraph

public AdjListGraph(Graph g,
                    ListenerManager listenerManager)
Constructs a new instance of an AdjListGraph from an instance of any Graph implementation. Copies all nodes and edges from g into the new graph.

Parameters:
g - any Graph implementation out of which an AdjListGraph shall be generated.
listenerManager - listener manager for the graph.

AdjListGraph

public AdjListGraph(Graph g,
                    ListenerManager listenerManager,
                    CollectionAttribute coll)
Constructs a new instance of an AdjListGraph from an instance of any Graph implementation. Copies all nodes and edges from g into the new graph.

Parameters:
g - any Graph implementation out of which an AdjListGraph shall be generated.
listenerManager - listener manager for the graph.
coll - the CollectionAttribute of the currently created AdjListGraph instance.
Method Detail

setNodeFirst

public void setNodeFirst(Node node)
The given node is moved to the front of the node list.

Parameters:
node -

setNodeLast

public void setNodeLast(Node node)
The given node is moved to the end of the node list.

Parameters:
node -

getNodesIterator

public Iterator<Node> getNodesIterator()
Returns an iterator over the nodes of the graph. Note that the remove operation is not supported by this iterator.

Specified by:
getNodesIterator in interface Graph
Returns:
an iterator containing the nodes of the graph.

copy

public Object copy()
Creates and returns a copy of the graph. The attributes are copied as well as all nodes and edges.

Specified by:
copy in interface DeepCopy
Returns:
a copy of the graph.

createNode

public Node createNode(CollectionAttribute col)
Creates a new AdjListNode that is in the current graph. And initializes it with the given CollectionAttribute.

Specified by:
createNode in interface Graph
Specified by:
createNode in class AbstractGraph
Parameters:
col - DOCUMENT ME!
Returns:
the newly created node.

createEdge

public Edge createEdge(Node source,
                       Node target,
                       boolean directed,
                       CollectionAttribute col)
Creates a new AdjListEdge that is in the current graph. And initializes it with the given CollectionAttribute.

Specified by:
createEdge in interface Graph
Parameters:
source - the source of the edge to add.
target - the target of the edge to add.
directed - true if the edge shall be directed, false otherwise.
col - CollectionAttribute that will be added to the new Edge
Returns:
the new edge.

isModified

public boolean isModified()
Description copied from interface: Graph
Indicates whether the Graph has been modified. A call to setModified can change this property to false e.g. after the graph has been saved to disc. Changes to attributes and delete/add commands of nodes and edges should change this property to true.

Specified by:
isModified in interface Graph
Returns:
True, if the graph has been modifed, False if not.

setModified

public void setModified(boolean modified)
Description copied from interface: Graph
Should be set to False after saving changes and to True after making changes to the Graph. The add/delete nodes and edges commands as well as the property change methods should set this value to True.

Specified by:
setModified in interface Graph
Parameters:
modified - Indicates the new status of this field.


Generated at 2012-05-30 11:00:14 PM CEST