Class Graph<N extends GraphNode,E extends GraphEdge>

java.lang.Object
org.jtool.graph.Graph<N,E>
Type Parameters:
N - The type of nodes in this graph
E - The type of edges in this graph
Direct Known Subclasses:
CFG, PDG

public class Graph<N extends GraphNode,E extends GraphEdge> extends Object
A graph object having nodes and edges.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected List<E>
    Edges of this graph.
    protected Set<N>
    Nodes of this graph.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new, empty object for storing a graph information.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(E edge)
    Adds a given edge to this graph.
    void
    add(N node)
    Adds a given node to this graph.
    void
    addEdges(List<E> edges)
    Sets edges of this graph.
    void
    addNodes(Set<N> nodes)
    Adds nodes of this graph.
    void
    Clears all nodes and all edges of this graph.
    boolean
    contains(E edge)
    Tests if this graph contains a given edge.
    boolean
    contains(N node)
    Tests if this graph contains a given node.
    Returns all edges of this graph.
    Returns all nodes of this graph.
    void
    remove(E edge)
    Removes a given edge from this graph.
    void
    remove(N node)
    Removes a given node from this graph.
    Obtains information on this graph.
    protected String
    Obtains information on all edges enclosed in this graph.
    protected String
    Obtains information on all nodes enclosed in this graph.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • nodes

      protected Set<N extends GraphNode> nodes
      Nodes of this graph.
    • edges

      protected List<E extends GraphEdge> edges
      Edges of this graph.
  • Constructor Details

    • Graph

      public Graph()
      Creates a new, empty object for storing a graph information.
  • Method Details

    • clear

      public void clear()
      Clears all nodes and all edges of this graph.
    • getNodes

      public Set<N> getNodes()
      Returns all nodes of this graph.
      Returns:
      the collection of the nodes
    • getEdges

      public List<E> getEdges()
      Returns all edges of this graph.
      Returns:
      the collection of the edges
    • addNodes

      public void addNodes(Set<N> nodes)
      Adds nodes of this graph.
      Parameters:
      nodes - a collection of nodes to be added
    • addEdges

      public void addEdges(List<E> edges)
      Sets edges of this graph.
      Parameters:
      edges - a collection of edges to be added
    • add

      public void add(N node)
      Adds a given node to this graph.
      Parameters:
      node - the node to be added
    • add

      public void add(E edge)
      Adds a given edge to this graph.
      Parameters:
      edge - the edge to be added
    • remove

      public void remove(N node)
      Removes a given node from this graph.
      Parameters:
      node - the node to be removed
    • remove

      public void remove(E edge)
      Removes a given edge from this graph.
      Parameters:
      edge - the edge to be removed
    • contains

      public boolean contains(N node)
      Tests if this graph contains a given node.
      Parameters:
      node - the node to be checked
      Returns:
      true if this graph contains the node, otherwise false
    • contains

      public boolean contains(E edge)
      Tests if this graph contains a given edge.
      Parameters:
      edge - the edge to be checked
      Returns:
      true if this graph contains the edge, otherwise false
    • toString

      public String toString()
      Obtains information on this graph.
      Overrides:
      toString in class Object
      Returns:
      the string representing the information
    • toStringForNodes

      protected String toStringForNodes()
      Obtains information on all nodes enclosed in this graph.
      Returns:
      the string representing the information
    • toStringForEdges

      protected String toStringForEdges()
      Obtains information on all edges enclosed in this graph.
      Returns:
      the string representing the information