Class SimpleGraph<N>

java.lang.Object
pascal.taie.util.graph.SimpleGraph<N>
Type Parameters:
N - type of nodes
All Implemented Interfaces:
Serializable, Iterable<N>, Graph<N>

public class SimpleGraph<N> extends Object implements Graph<N>
A simple map-based implementation of Graph.
See Also:
  • Constructor Details

    • SimpleGraph

      public SimpleGraph()
      Constructs an empty graph.
    • SimpleGraph

      public SimpleGraph(Graph<N> graph)
      Constructs a new graph containing the same node and edge sets as the specified graph.
  • Method Details

    • addNode

      public void addNode(N node)
    • addEdge

      public void addEdge(N source, N target)
    • removeNode

      public void removeNode(N node)
      Removes a node from this graph. All edges from/to the node will also be removed.
    • removeEdge

      public void removeEdge(N source, N target)
      Removes an edge from this graph.
    • getPredsOf

      public Set<N> getPredsOf(N node)
      Specified by:
      getPredsOf in interface Graph<N>
      Returns:
      the predecessors of given node in this graph.
    • getSuccsOf

      public Set<N> getSuccsOf(N node)
      Specified by:
      getSuccsOf in interface Graph<N>
      Returns:
      the successors of given node in this graph.
    • getInDegreeOf

      public int getInDegreeOf(N node)
      Specified by:
      getInDegreeOf in interface Graph<N>
      Returns:
      the number of in edges of the given node.
    • getNodes

      public Set<N> getNodes()
      Specified by:
      getNodes in interface Graph<N>
      Returns:
      all nodes of this graph.