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 anAdjListGraph
from an instance of anyGraph
implementation.AdjListGraph(Graph g, ListenerManager listenerManager, CollectionAttribute coll)
Constructs a new instance of anAdjListGraph
from an instance of anyGraph
implementation. -
Method Summary
Modifier and Type Method Description void
checkMaxGraphElementId(long id)
Deprecated.Object
copy()
Creates and returns a copy of the graph.void
deleteAll(Collection<? extends GraphElement> graphelements)
Collection<Edge>
getEdges()
Returns ajava.util.Collection
containing 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.String
getFileTypeDescription()
Returns a file type description which can be used to choose an appropriate output serializer independent of the file extension.String
getName()
String
getName(boolean fullName)
List<Node>
getNodes()
Returns ajava.util.List
containing all the nodes of theGraph
.Iterator<Node>
getNodesIterator()
Returns an iterator over the nodes of the graph.int
getNumberOfEdges()
Returns the number of edges of the graph.int
getNumberOfNodes()
Returns the number of nodes in the graph.boolean
isModified()
Indicates whether theGraph
has been modified.void
numberGraphElements()
Empty implementation, since we do not support this anymorevoid
setFileTypeDescription(String fileTypeDescription)
Sets a file type description which can be used to choose an appropriate output serializer independent of the file extension.void
setListenerManager(ListenerManager l)
void
setModified(boolean modified)
Should be set to False after saving changes and to True after making changes to the Graph.void
setName(String name)
The name can be retrieved with the methodgetName
.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.String
toString()
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, 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, 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, wait, wait, wait
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, getAttribute, getAttributes, getBoolean, getByte, getDouble, getFloat, getInteger, getListenerManager, getLong, getShort, getString, removeAttribute, setBoolean, setByte, setDouble, setFloat, setInteger, setLong, setShort, setString
Methods 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 theListenerManager
of the new instance to the defaultListenerManager
. -
AdjListGraph
Constructs a new instance of anAdjListGraph
. Sets theListenerManager
of the new instance to the defaultListenerManager
.- Parameters:
coll
- theCollectionAttribute
of the currently createdAdjListGraph
instance.
-
AdjListGraph
Constructs a new instance of anAdjListGraph
. Sets theListenerManager
of the new instance to the specified one.- Parameters:
listenerManager
- listener manager for the graph.
-
AdjListGraph
Constructs a new instance of anAdjListGraph
. Sets theListenerManager
of the new instance to the specified one.- Parameters:
listenerManager
- listener manager for the graph.coll
- theCollectionAttribute
of the currently createdAdjListGraph
instance.
-
AdjListGraph
Constructs a new instance of anAdjListGraph
from an instance of anyGraph
implementation. Copies all nodes and edges from g into the new graph.- Parameters:
g
- anyGraph
implementation out of which anAdjListGraph
shall be generated.listenerManager
- listener manager for the graph.
-
AdjListGraph
Constructs a new instance of anAdjListGraph
from an instance of anyGraph
implementation. Copies all nodes and edges from g into the new graph.- Parameters:
g
- anyGraph
implementation out of which anAdjListGraph
shall be generated.listenerManager
- listener manager for the graph.coll
- theCollectionAttribute
of the currently createdAdjListGraph
instance.
-
-
Method Details
-
toString
-
getNumberOfNodes
public int getNumberOfNodes()Description copied from class:AbstractGraph
Returns the number of nodes in the graph.- Specified by:
getNumberOfNodes
in interfaceGraph
- Overrides:
getNumberOfNodes
in classAbstractGraph
- Returns:
- the number of nodes of the graph.
-
getNodes
Description copied from interface:Graph
Returns ajava.util.List
containing 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:
getNodesIterator
in 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:Graph
Indicates whether theGraph
has been modified. A call tosetModified
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 totrue
.- Specified by:
isModified
in interfaceGraph
- 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 interfaceGraph
- Parameters:
modified
- Indicates the new status of this field.
-
getEdges
Description copied from class:AbstractGraph
Returns ajava.util.Collection
containing all the edges of the current graph.- Specified by:
getEdges
in interfaceGraph
- Overrides:
getEdges
in classAbstractGraph
- Returns:
- a
java.util.Collection
containing all the edges of the current graph.
-
getNumberOfEdges
public int getNumberOfEdges()Description copied from class:AbstractGraph
Returns the number of edges of the graph.- Specified by:
getNumberOfEdges
in interfaceGraph
- Overrides:
getNumberOfEdges
in classAbstractGraph
- Returns:
- the number of edges of the graph.
-
getEdges
Description copied from class:AbstractGraph
Returns 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:
getEdges
in interfaceGraph
- Overrides:
getEdges
in classAbstractGraph
- Parameters:
n1
- the first node.n2
- the second node.- Returns:
- a
Collection
containing all edges between n1 and n2, an empty collection if there is no edge between the two nodes.
-
deleteAll
-
setName
Description copied from interface:Graph
The name can be retrieved with the methodgetName
. -
getName
-
getName
-
numberGraphElements
public void numberGraphElements()Empty implementation, since we do not support this anymore- Specified by:
numberGraphElements
in interfaceGraph
-
checkMaxGraphElementId
Deprecated.- Specified by:
checkMaxGraphElementId
in interfaceGraph
-
setListenerManager
- Specified by:
setListenerManager
in interfaceGraph
-
setFileTypeDescription
Sets a file type description which can be used to choose an appropriate output serializer independent of the file extension.- Specified by:
setFileTypeDescription
in 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:
getFileTypeDescription
in interfaceGraph
- Returns:
- a file type description
-