Package org.graffiti.graph
Class AdjListGraph
java.lang.Object
org.graffiti.attributes.AbstractAttributable
org.graffiti.graph.AbstractGraph
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: 1.12.4.1.2.1 $
- See Also:
Graph,AbstractGraph,AdjListNode,AdjListEdge,AbstractNode,AbstractEdge- Recent revisions:
- 2.7.0
-
Constructor Summary
Constructors Constructor Description AdjListGraph()Constructs a new instance of anAdjListGraph.AdjListGraph(CollectionAttribute coll)Constructs a new instance of anAdjListGraph.AdjListGraph(ListenerManager listenerManager)Constructs a new instance of anAdjListGraph.AdjListGraph(ListenerManager listenerManager, CollectionAttribute coll)Constructs a new instance of anAdjListGraph.AdjListGraph(Graph g, ListenerManager listenerManager)Constructs a new instance of anAdjListGraphfrom an instance of anyGraphimplementation.AdjListGraph(Graph g, ListenerManager listenerManager, CollectionAttribute coll)Constructs a new instance of anAdjListGraphfrom an instance of anyGraphimplementation. -
Method Summary
Modifier and Type Method Description voidcheckMaxGraphElementId(long id)Deprecated.Objectcopy()Creates and returns a copy of the graph.voiddeleteAll(Collection<? extends GraphElement> graphelements)Collection<Edge>getEdges()Returns ajava.util.Collectioncontaining all the edges of the current graph.Collection<Edge>getEdges(Node n1, Node n2)Returns a collection containing all the edges between n1 and n2.StringgetFileTypeDescription()Returns a file type description which can be used to choose an appropriate output serializer independent of the file extension.StringgetName()StringgetName(boolean fullName)List<Node>getNodes()Returns ajava.util.Listcontaining all the nodes of theGraph.Iterator<Node>getNodesIterator()Returns an iterator over the nodes of the graph.intgetNumberOfEdges()Returns the number of edges of the graph.intgetNumberOfNodes()Returns the number of nodes in the graph.booleanisModified()Indicates whether theGraphhas been modified.voidnumberGraphElements()Empty implementation, since we do not support this anymorevoidsetFileTypeDescription(String fileTypeDescription)Sets a file type description which can be used to choose an appropriate output serializer independent of the file extension.voidsetListenerManager(ListenerManager l)voidsetModified(boolean modified)Should be set to False after saving changes and to True after making changes to the Graph.voidsetName(String name)The name can be retrieved with the methodgetName.voidsetNodeFirst(Node node)The given node is moved to the front of the node list.voidsetNodeLast(Node node)The given node is moved to the end of the node list.StringtoString()Methods inherited from class org.graffiti.graph.AbstractGraph
addAttributeConsumer, addEdge, addEdge, addEdgeCopy, addGraph, addNode, addNode, addNodeCopy, areConnected, clear, containsEdge, containsNode, deleteEdge, deleteNode, generateNextUniqueGraphElementId, getAttTypesManager, getCurrentMaxGraphElementId, getEdgesIterator, getGraphElements, getListenerManager, getNumberOfDirectedEdges, getNumberOfUndirectedEdges, isDirected, isEmpty, isUndirected, 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, clear, containsEdge, containsNode, deleteEdge, deleteNode, generateNextUniqueGraphElementId, getAttTypesManager, getCurrentMaxGraphElementId, getEdgesIterator, getGraphElements, getNumberOfDirectedEdges, getNumberOfUndirectedEdges, isDirected, isEmpty, isUndirected, removeAttributeConsumer, setDirected, setDirected
-
Constructor Details
-
AdjListGraph
public AdjListGraph()Constructs a new instance of anAdjListGraph. Sets theListenerManagerof the new instance to the defaultListenerManager. -
AdjListGraph
Constructs a new instance of anAdjListGraph. Sets theListenerManagerof the new instance to the defaultListenerManager.- Parameters:
coll- theCollectionAttributeof the currently createdAdjListGraphinstance.
-
AdjListGraph
Constructs a new instance of anAdjListGraph. Sets theListenerManagerof the new instance to the specified one.- Parameters:
listenerManager- listener manager for the graph.
-
AdjListGraph
Constructs a new instance of anAdjListGraph. Sets theListenerManagerof the new instance to the specified one.- Parameters:
listenerManager- listener manager for the graph.coll- theCollectionAttributeof the currently createdAdjListGraphinstance.
-
AdjListGraph
Constructs a new instance of anAdjListGraphfrom an instance of anyGraphimplementation. Copies all nodes and edges from g into the new graph.- Parameters:
g- anyGraphimplementation out of which anAdjListGraphshall be generated.listenerManager- listener manager for the graph.
-
AdjListGraph
Constructs a new instance of anAdjListGraphfrom an instance of anyGraphimplementation. Copies all nodes and edges from g into the new graph.- Parameters:
g- anyGraphimplementation out of which anAdjListGraphshall be generated.listenerManager- listener manager for the graph.coll- theCollectionAttributeof the currently createdAdjListGraphinstance.
-
-
Method Details
-
toString
-
getNumberOfNodes
public int getNumberOfNodes()Description copied from class:AbstractGraphReturns the number of nodes in the graph.- Specified by:
getNumberOfNodesin interfaceGraph- Overrides:
getNumberOfNodesin classAbstractGraph- Returns:
- the number of nodes of the graph.
-
getNodes
Description copied from interface:GraphReturns ajava.util.Listcontaining all the nodes of theGraph. -
setNodeFirst
The given node is moved to the front of the node list.- Parameters:
node-
-
setNodeLast
The given node is moved to the end of the node list.- Parameters:
node-
-
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- Returns:
- an iterator containing the nodes of the graph.
-
copy
Creates and returns a copy of the graph. The attributes are copied as well as all nodes and edges. -
isModified
public boolean isModified()Description copied from interface:GraphIndicates whether theGraphhas been modified. A call tosetModifiedcan 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 totrue.- Specified by:
isModifiedin interfaceGraph- Returns:
- True, if the graph has been modifed, False if not.
-
setModified
public void setModified(boolean modified)Description copied from interface:GraphShould 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:
setModifiedin interfaceGraph- Parameters:
modified- Indicates the new status of this field.
-
getEdges
Description copied from class:AbstractGraphReturns ajava.util.Collectioncontaining all the edges of the current graph.- Specified by:
getEdgesin interfaceGraph- Overrides:
getEdgesin classAbstractGraph- Returns:
- a
java.util.Collectioncontaining all the edges of the current graph.
-
getNumberOfEdges
public int getNumberOfEdges()Description copied from class:AbstractGraphReturns the number of edges of the graph.- Specified by:
getNumberOfEdgesin interfaceGraph- Overrides:
getNumberOfEdgesin classAbstractGraph- Returns:
- the number of edges of the graph.
-
getEdges
Description copied from class:AbstractGraphReturns a collection containing all the edges between n1 and n2. There can be more than one edge between two nodes. The edges returned by this method can go from n1 to n2 or vice versa, be directed or not.- Specified by:
getEdgesin interfaceGraph- Overrides:
getEdgesin classAbstractGraph- Parameters:
n1- the first node.n2- the second node.- Returns:
- a
Collectioncontaining all edges between n1 and n2, an empty collection if there is no edge between the two nodes.
-
deleteAll
-
setName
Description copied from interface:GraphThe name can be retrieved with the methodgetName. -
getName
-
getName
-
numberGraphElements
public void numberGraphElements()Empty implementation, since we do not support this anymore- Specified by:
numberGraphElementsin interfaceGraph
-
checkMaxGraphElementId
Deprecated.- Specified by:
checkMaxGraphElementIdin interfaceGraph
-
setListenerManager
- Specified by:
setListenerManagerin interfaceGraph
-
setFileTypeDescription
Sets a file type description which can be used to choose an appropriate output serializer independent of the file extension.- Specified by:
setFileTypeDescriptionin interfaceGraph- Parameters:
fileTypeDescription-
-
getFileTypeDescription
Returns a file type description which can be used to choose an appropriate output serializer independent of the file extension.- Specified by:
getFileTypeDescriptionin interfaceGraph- Returns:
- a file type description
-