org.graffiti.graph
Class OptAdjListGraph

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

public class OptAdjListGraph
extends AdjListGraph
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
OptAdjListGraph()
          Constructs a new instance of an OptAdjListGraph.
OptAdjListGraph(CollectionAttribute coll)
          Constructs a new instance of an OptAdjListGraph.
OptAdjListGraph(Graph g, ListenerManager listenerManager)
          Constructs a new instance of an OptAdjListGraph from an instance of any Graph implementation.
OptAdjListGraph(Graph g, ListenerManager listenerManager, CollectionAttribute coll)
          Constructs a new instance of an OptAdjListGraph from an instance of any Graph implementation.
OptAdjListGraph(ListenerManager listenerManager)
          Constructs a new instance of an OptAdjListGraph.
OptAdjListGraph(ListenerManager listenerManager, CollectionAttribute coll)
          Constructs a new instance of an OptAdjListGraph.
 
Method Summary
 boolean containsEdge(Edge e)
          Returns true, if the graph contains the specified edge, false otherwise.
 boolean containsNode(Node n)
          Returns true, if the graph contains the specified node, false otherwise.
 Object copy()
          Creates and returns a copy of the graph.
 Collection<Edge> getEdges()
          Returns a java.util.Collection containing all the edges of the current graph.
 Iterator<Edge> getEdgesIterator()
          Returns an iterator over the edges of the graph.
 List<Node> getNodes()
          Returns a list containing a copy of the node list of the graph.
 Iterator<Node> getNodesIterator()
          Returns an iterator over the nodes of the graph.
 int getNumberOfDirectedEdges()
          Returns the number of directed edges of the graph.
 int getNumberOfEdges()
          Returns the number of edges of the graph.
 int getNumberOfNodes()
          Returns the number of nodes in the graph.
 int getNumberOfUndirectedEdges()
          Returns the number of undirected edges in the graph.
 boolean isDirected()
          Indicates whether the graph is directed.
 boolean isEmpty()
          Returns true if the graph is empty.
 boolean isUndirected()
          Indicates whether the graph is undirected.
 void setDirected(boolean directed)
          Sets all edges to be directed.
 void setDirected(boolean directed, boolean adjustArrows)
          When passing a true value, all undirected edges in the graph will be set to be directed.
 
Methods inherited from class org.graffiti.graph.AdjListGraph
createEdge, createNode, isModified, setModified, setNodeFirst, setNodeLast
 
Methods inherited from class org.graffiti.graph.AbstractGraph
addAttributeConsumer, addEdge, addEdge, addEdgeCopy, addGraph, addNode, addNode, addNodeCopy, areConnected, clear, deleteEdge, deleteNode, getAttTypesManager, getEdges, getGraphElements, getListenerManager, removeAttributeConsumer
 
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, createEdge, createNode, deleteEdge, deleteNode, getAttTypesManager, getEdges, getGraphElements, isModified, removeAttributeConsumer, setModified
 
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

OptAdjListGraph

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


OptAdjListGraph

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

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

OptAdjListGraph

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

Parameters:
listenerManager - listener manager for the graph.

OptAdjListGraph

public OptAdjListGraph(ListenerManager listenerManager,
                       CollectionAttribute coll)
Constructs a new instance of an OptAdjListGraph. 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 OptAdjListGraph instance.

OptAdjListGraph

public OptAdjListGraph(Graph g,
                       ListenerManager listenerManager)
Constructs a new instance of an OptAdjListGraph 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 OptAdjListGraph shall be generated.
listenerManager - listener manager for the graph.

OptAdjListGraph

public OptAdjListGraph(Graph g,
                       ListenerManager listenerManager,
                       CollectionAttribute coll)
Constructs a new instance of an OptAdjListGraph 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 OptAdjListGraph shall be generated.
listenerManager - listener manager for the graph.
coll - the CollectionAttribute of the currently created OptAdjListGraph instance.
Method Detail

isDirected

public boolean isDirected()
Indicates whether the graph is directed. A graph is directed if all the edges are directed.

Specified by:
isDirected in interface Graph
Overrides:
isDirected in class AbstractGraph
Returns:
a boolean indicating whether the graph is directed.

setDirected

public void setDirected(boolean directed)
Sets all edges to be directed.

If directed is true, standard arrows are set, if it is false, all arrows of all edges are removed.

Specified by:
setDirected in interface Graph
Overrides:
setDirected in class AbstractGraph
See Also:
Graph.setDirected(boolean)

setDirected

public void setDirected(boolean directed,
                        boolean adjustArrows)
When passing a true value, all undirected edges in the graph will be set to be directed. V.v. for a false value. A true second parameter indicates that all edges shall get one arrow at their tips (i.e. close to the target node).

Specified by:
setDirected in interface Graph
Overrides:
setDirected in class AbstractGraph
Parameters:
directed -
adjustArrows -

getEdges

public Collection<Edge> getEdges()
Returns a java.util.Collection containing all the edges of the current graph.

Specified by:
getEdges in interface Graph
Overrides:
getEdges in class AbstractGraph
Returns:
a java.util.Collection containing all the edges of the current graph.

getEdgesIterator

public Iterator<Edge> getEdgesIterator()
Returns an iterator over the edges of the graph. Note that the remove operation is not supported by this iterator.

Specified by:
getEdgesIterator in interface Graph
Overrides:
getEdgesIterator in class AbstractGraph
Returns:
an iterator containing the edges of the graph.

isEmpty

public boolean isEmpty()
Returns true if the graph is empty. The graph is equal to a graph which has been cleared.

Specified by:
isEmpty in interface Graph
Overrides:
isEmpty in class AbstractGraph
Returns:
true if the graph is empty, false otherwise.

getNodes

public List<Node> getNodes()
Returns a list containing a copy of the node list of the graph. Removing elements from this collection will have no effect on the graph whereas nodes can be modified.

Specified by:
getNodes in interface Graph
Overrides:
getNodes in class AbstractGraph
Returns:
a new java.util.List containing all the nodes of the graph.

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
Overrides:
getNodesIterator in class AdjListGraph
Returns:
an iterator containing the nodes of the graph.

getNumberOfDirectedEdges

public int getNumberOfDirectedEdges()
Returns the number of directed edges of the graph.

Specified by:
getNumberOfDirectedEdges in interface Graph
Overrides:
getNumberOfDirectedEdges in class AbstractGraph
Returns:
the number of directed edges of the graph.

getNumberOfEdges

public int getNumberOfEdges()
Returns the number of edges of the graph.

Specified by:
getNumberOfEdges in interface Graph
Overrides:
getNumberOfEdges in class AbstractGraph
Returns:
the number of edges of the graph.

getNumberOfNodes

public int getNumberOfNodes()
Returns the number of nodes in the graph.

Specified by:
getNumberOfNodes in interface Graph
Overrides:
getNumberOfNodes in class AbstractGraph
Returns:
the number of nodes of the graph.

getNumberOfUndirectedEdges

public int getNumberOfUndirectedEdges()
Returns the number of undirected edges in the graph.

Specified by:
getNumberOfUndirectedEdges in interface Graph
Overrides:
getNumberOfUndirectedEdges in class AbstractGraph
Returns:
the number of undirected edges in the graph.

isUndirected

public boolean isUndirected()
Indicates whether the graph is undirected. A graph is undirected if all the edges are undirected.

Specified by:
isUndirected in interface Graph
Overrides:
isUndirected in class AbstractGraph
Returns:
A boolean indicating whether the graph is undirected.

containsEdge

public boolean containsEdge(Edge e)
Returns true, if the graph contains the specified edge, false otherwise.

Specified by:
containsEdge in interface Graph
Overrides:
containsEdge in class AbstractGraph
Parameters:
e - the edge to search for.
Returns:
true, if the graph contains the edge e, false otherwise.

containsNode

public boolean containsNode(Node n)
Returns true, if the graph contains the specified node, false otherwise.

Specified by:
containsNode in interface Graph
Overrides:
containsNode in class AbstractGraph
Parameters:
n - the node to search for.
Returns:
true, if the graph contains the node n, false otherwise.

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
Overrides:
copy in class AdjListGraph
Returns:
a copy of the graph.


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