Package org.graffiti.graph
Class OptAdjListGraph
java.lang.Object
org.graffiti.attributes.AbstractAttributable
org.graffiti.graph.AbstractGraph
org.graffiti.graph.AdjListGraph
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: 1.7 $
- See Also:
Graph,AbstractGraph,AdjListNode,AdjListEdge,AbstractNode,AbstractEdge
-
Constructor Summary
Constructors Constructor Description OptAdjListGraph()Constructs a new instance of anOptAdjListGraph.OptAdjListGraph(CollectionAttribute coll)Constructs a new instance of anOptAdjListGraph.OptAdjListGraph(ListenerManager listenerManager)Constructs a new instance of anOptAdjListGraph.OptAdjListGraph(ListenerManager listenerManager, CollectionAttribute coll)Constructs a new instance of anOptAdjListGraph.OptAdjListGraph(Graph g, ListenerManager listenerManager)Constructs a new instance of anOptAdjListGraphfrom an instance of anyGraphimplementation.OptAdjListGraph(Graph g, ListenerManager listenerManager, CollectionAttribute coll)Constructs a new instance of anOptAdjListGraphfrom an instance of anyGraphimplementation. -
Method Summary
Modifier and Type Method Description booleancontainsEdge(Edge e)Returnstrue, if the graph contains the specified edge,falseotherwise.booleancontainsNode(Node n)Returnstrue, if the graph contains the specified node,falseotherwise.Objectcopy()Creates and returns a copy of the graph.Collection<Edge>getEdges()Returns ajava.util.Collectioncontaining 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.intgetNumberOfDirectedEdges()Returns the number of directed edges of the graph.intgetNumberOfEdges()Returns the number of edges of the graph.intgetNumberOfNodes()Returns the number of nodes in the graph.intgetNumberOfUndirectedEdges()Returns the number of undirected edges in the graph.booleanisDirected()Indicates whether the graph is directed.booleanisEmpty()Returnstrueif the graph is empty.booleanisUndirected()Indicates whether the graph is undirected.Methods inherited from class org.graffiti.graph.AdjListGraph
checkMaxGraphElementId, deleteAll, getEdges, getFileTypeDescription, getName, getName, isModified, numberGraphElements, setFileTypeDescription, setListenerManager, setModified, setName, setNodeFirst, setNodeLast, toStringMethods inherited from class org.graffiti.graph.AbstractGraph
addAttributeConsumer, addEdge, addEdge, addEdgeCopy, addGraph, addNode, addNode, addNodeCopy, areConnected, clear, deleteEdge, deleteNode, generateNextUniqueGraphElementId, getAttTypesManager, getCurrentMaxGraphElementId, getGraphElements, getListenerManager, removeAttributeConsumer, setDirected, setDirectedMethods inherited from class org.graffiti.attributes.AbstractAttributable
addAttribute, addBoolean, addByte, addDouble, addFloat, addInteger, addLong, addShort, addString, changeBoolean, changeByte, changeDouble, changeFloat, changeInteger, changeLong, changeShort, changeString, getAttribute, getAttributes, getBoolean, getByte, getDouble, getFloat, getInteger, getLong, getShort, getString, removeAttribute, setBoolean, setByte, setDouble, setFloat, setInteger, setLong, setShort, setStringMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.graffiti.attributes.Attributable
addAttribute, addBoolean, addByte, addDouble, addFloat, addInteger, addLong, addShort, addString, changeBoolean, changeByte, changeDouble, changeFloat, changeInteger, changeLong, changeShort, changeString, getAttribute, getAttributes, getBoolean, getByte, getDouble, getFloat, getInteger, getListenerManager, getLong, getShort, getString, removeAttribute, setBoolean, setByte, setDouble, setFloat, setInteger, setLong, setShort, setStringMethods inherited from interface org.graffiti.graph.Graph
addAttributeConsumer, addEdge, addEdge, addEdgeCopy, addGraph, addNode, addNode, addNodeCopy, checkMaxGraphElementId, clear, deleteAll, deleteEdge, deleteNode, generateNextUniqueGraphElementId, getAttTypesManager, getCurrentMaxGraphElementId, getEdges, getFileTypeDescription, getGraphElements, getName, getName, isModified, numberGraphElements, removeAttributeConsumer, setDirected, setDirected, setFileTypeDescription, setListenerManager, setModified, setName
-
Constructor Details
-
OptAdjListGraph
public OptAdjListGraph()Constructs a new instance of anOptAdjListGraph. Sets theListenerManagerof the new instance to the defaultListenerManager. -
OptAdjListGraph
Constructs a new instance of anOptAdjListGraph. Sets theListenerManagerof the new instance to the defaultListenerManager.- Parameters:
coll- theCollectionAttributeof the currently createdOptAdjListGraphinstance.
-
OptAdjListGraph
Constructs a new instance of anOptAdjListGraph. Sets theListenerManagerof the new instance to the specified one.- Parameters:
listenerManager- listener manager for the graph.
-
OptAdjListGraph
Constructs a new instance of anOptAdjListGraph. Sets theListenerManagerof the new instance to the specified one.- Parameters:
listenerManager- listener manager for the graph.coll- theCollectionAttributeof the currently createdOptAdjListGraphinstance.
-
OptAdjListGraph
Constructs a new instance of anOptAdjListGraphfrom an instance of anyGraphimplementation. Copies all nodes and edges from g into the new graph.- Parameters:
g- anyGraphimplementation out of which anOptAdjListGraphshall be generated.listenerManager- listener manager for the graph.
-
OptAdjListGraph
Constructs a new instance of anOptAdjListGraphfrom an instance of anyGraphimplementation. Copies all nodes and edges from g into the new graph.- Parameters:
g- anyGraphimplementation out of which anOptAdjListGraphshall be generated.listenerManager- listener manager for the graph.coll- theCollectionAttributeof the currently createdOptAdjListGraphinstance.
-
-
Method Details
-
isDirected
public boolean isDirected()Indicates whether the graph is directed. A graph is directed if graph setting states this.- Specified by:
isDirectedin interfaceGraph- Overrides:
isDirectedin classAbstractGraph- Returns:
- a boolean indicating whether the graph is directed.
-
getEdges
Returns ajava.util.Collectioncontaining all the edges of the current graph.- Specified by:
getEdgesin interfaceGraph- Overrides:
getEdgesin classAdjListGraph- Returns:
- a
java.util.Collectioncontaining all the edges of the current graph.
-
getEdgesIterator
Returns an iterator over the edges of the graph. Note that the remove operation is not supported by this iterator.- Specified by:
getEdgesIteratorin interfaceGraph- Overrides:
getEdgesIteratorin classAbstractGraph- Returns:
- an iterator containing the edges of the graph.
-
isEmpty
public boolean isEmpty()Returnstrueif the graph is empty. The graph is equal to a graph which has been cleared.- Specified by:
isEmptyin interfaceGraph- Overrides:
isEmptyin classAbstractGraph- Returns:
trueif the graph is empty,falseotherwise.
-
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:
getNodesin interfaceGraph- Overrides:
getNodesin classAdjListGraph- Returns:
- a new
java.util.Listcontaining all the nodes of the graph.
-
getNodesIterator
Returns an iterator over the nodes of the graph. Note that the remove operation is not supported by this iterator.- Specified by:
getNodesIteratorin interfaceGraph- Overrides:
getNodesIteratorin classAdjListGraph- Returns:
- an iterator containing the nodes of the graph.
-
getNumberOfDirectedEdges
public int getNumberOfDirectedEdges()Returns the number of directed edges of the graph.- Specified by:
getNumberOfDirectedEdgesin interfaceGraph- Overrides:
getNumberOfDirectedEdgesin classAbstractGraph- Returns:
- the number of directed edges of the graph.
-
getNumberOfEdges
public int getNumberOfEdges()Returns the number of edges of the graph.- Specified by:
getNumberOfEdgesin interfaceGraph- Overrides:
getNumberOfEdgesin classAdjListGraph- Returns:
- the number of edges of the graph.
-
getNumberOfNodes
public int getNumberOfNodes()Returns the number of nodes in the graph.- Specified by:
getNumberOfNodesin interfaceGraph- Overrides:
getNumberOfNodesin classAdjListGraph- Returns:
- the number of nodes of the graph.
-
getNumberOfUndirectedEdges
public int getNumberOfUndirectedEdges()Returns the number of undirected edges in the graph.- Specified by:
getNumberOfUndirectedEdgesin interfaceGraph- Overrides:
getNumberOfUndirectedEdgesin classAbstractGraph- 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:
isUndirectedin interfaceGraph- Overrides:
isUndirectedin classAbstractGraph- Returns:
- A boolean indicating whether the graph is undirected.
-
containsEdge
Returnstrue, if the graph contains the specified edge,falseotherwise.- Specified by:
containsEdgein interfaceGraph- Overrides:
containsEdgein classAbstractGraph- Parameters:
e- the edge to search for.- Returns:
true, if the graph contains the edge e,falseotherwise.
-
containsNode
Returnstrue, if the graph contains the specified node,falseotherwise.- Specified by:
containsNodein interfaceGraph- Overrides:
containsNodein classAbstractGraph- Parameters:
n- the node to search for.- Returns:
true, if the graph contains the node n,falseotherwise.
-
copy
Creates and returns a copy of the graph. The attributes are copied as well as all nodes and edges.- Specified by:
copyin interfaceDeepCopy- Overrides:
copyin classAdjListGraph- Returns:
- a copy of the graph.
-