Class 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 Details

    • 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 Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getNumberOfNodes

      public int getNumberOfNodes()
      Description copied from class: AbstractGraph
      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.
    • getNodes

      public List<Node> getNodes()
      Description copied from interface: Graph
      Returns a java.util.List containing all the nodes of the Graph.
      Specified by:
      getNodes in interface Graph
      Returns:
      a java.util.List containing all the nodes of the Graph.
    • 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.
    • 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.
    • getEdges

      public Collection<Edge> getEdges()
      Description copied from class: AbstractGraph
      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.
    • getNumberOfEdges

      public int getNumberOfEdges()
      Description copied from class: AbstractGraph
      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.
    • getEdges

      public Collection<Edge> getEdges​(Node n1, Node n2)
      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 interface Graph
      Overrides:
      getEdges in class AbstractGraph
      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

      public void deleteAll​(Collection<? extends GraphElement> graphelements)
      Specified by:
      deleteAll in interface Graph
    • setName

      public void setName​(String name)
      Description copied from interface: Graph
      The name can be retrieved with the method getName.
      Specified by:
      setName in interface Graph
      Parameters:
      name - A ID that can be used for identifying the graph - for the user or for the developer.
    • getName

      public String getName()
      Specified by:
      getName in interface Graph
      Returns:
      A ID that can be used for identifying the graph - for the user or for the developer. The name can be set with the method setName. Calls getName(false) to return a short name. E.g. just the filename and not the full name with file path.
    • getName

      public String getName​(boolean fullName)
      Specified by:
      getName in interface Graph
      Returns:
      A ID that can be used for identifying the graph - for the user or for the developer. The name can be set with the method setName.
    • numberGraphElements

      public void numberGraphElements()
      Empty implementation, since we do not support this anymore
      Specified by:
      numberGraphElements in interface Graph
    • checkMaxGraphElementId

      @Deprecated public void checkMaxGraphElementId​(long id)
      Deprecated.
      Specified by:
      checkMaxGraphElementId in interface Graph
    • setListenerManager

      public void setListenerManager​(ListenerManager l)
      Specified by:
      setListenerManager in interface Graph
    • setFileTypeDescription

      public void setFileTypeDescription​(String fileTypeDescription)
      Sets a file type description which can be used to choose an appropriate output serializer independent of the file extension.
      Specified by:
      setFileTypeDescription in interface Graph
      Parameters:
      fileTypeDescription -
    • getFileTypeDescription

      public String 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 interface Graph
      Returns:
      a file type description