Class DiGraph<N,E>

java.lang.Object
com.google.javascript.jscomp.graph.Graph<N,E>
com.google.javascript.jscomp.graph.DiGraph<N,E>
Type Parameters:
N - Value type that the graph node stores.
E - Value type that the graph edge stores.
All Implemented Interfaces:
AdjacencyGraph<N,E>
Direct Known Subclasses:
LinkedDirectedGraph

public abstract class DiGraph<N,E> extends Graph<N,E>
A generic directed graph.
  • Constructor Details

    • DiGraph

      public DiGraph()
  • Method Details

    • createNode

      public abstract DiGraph.DiGraphNode<N,E> createNode(N nodeValue)
      Description copied from class: Graph
      Gets a node from the graph given a value. New nodes are created if that value has not been assigned a graph node. Values equality are compared using Object.equals.
      Specified by:
      createNode in class Graph<N,E>
      Parameters:
      nodeValue - The node's value.
      Returns:
      The corresponding node in the graph.
    • getNodes

      public abstract Collection<? extends DiGraph.DiGraphNode<N,E>> getNodes()
      Description copied from class: Graph
      Gets an immutable list of all nodes.
      Specified by:
      getNodes in interface AdjacencyGraph<N,E>
      Specified by:
      getNodes in class Graph<N,E>
    • getNode

      public abstract DiGraph.DiGraphNode<N,E> getNode(N nodeValue)
      Description copied from interface: AdjacencyGraph
      Gets a node from the graph given a value. Values equality are compared using Object.equals.
      Parameters:
      nodeValue - The node's value.
      Returns:
      The corresponding node in the graph, null if there value has no corresponding node.
    • getEdges

      public abstract List<? extends DiGraph.DiGraphEdge<N,E>> getEdges()
      Description copied from class: Graph
      Gets an immutable list of all edges.
      Specified by:
      getEdges in class Graph<N,E>
    • getEdges

      public abstract List<? extends DiGraph.DiGraphEdge<N,E>> getEdges(N n1, N n2)
      Description copied from class: Graph
      Retrieves an edge from the graph.
      Specified by:
      getEdges in class Graph<N,E>
      Parameters:
      n1 - Node one.
      n2 - Node two.
      Returns:
      The list of edges between those two values in the graph.
    • getEdgesInDirection

      public abstract List<? extends DiGraph.DiGraphEdge<N,E>> getEdgesInDirection(N n1, N n2)
    • getOutEdges

      public abstract List<? extends DiGraph.DiGraphEdge<N,E>> getOutEdges(N nodeValue)
      Gets an immutable list of out edges of the given node.
    • getInEdges

      public abstract List<? extends DiGraph.DiGraphEdge<N,E>> getInEdges(N nodeValue)
      Gets an immutable list of in edges of the given node.
    • getDirectedPredNodes

      public abstract List<? extends DiGraph.DiGraphNode<N,E>> getDirectedPredNodes(DiGraph.DiGraphNode<N,E> n)
    • getDirectedPredNodes

      public abstract List<? extends DiGraph.DiGraphNode<N,E>> getDirectedPredNodes(N nodeValue)
    • getDirectedSuccNodes

      public abstract List<? extends DiGraph.DiGraphNode<N,E>> getDirectedSuccNodes(DiGraph.DiGraphNode<N,E> n)
    • getDirectedSuccNodes

      public abstract List<? extends DiGraph.DiGraphNode<N,E>> getDirectedSuccNodes(N nodeValue)
    • disconnectInDirection

      public abstract void disconnectInDirection(N n1, N n2)
      Disconnects all edges from n1 to n2.
      Parameters:
      n1 - Source node.
      n2 - Destination node.
    • isConnectedInDirection

      public abstract boolean isConnectedInDirection(N n1, N n2)
      Checks whether two nodes in the graph are connected via a directed edge.
      Parameters:
      n1 - Node 1.
      n2 - Node 2.
      Returns:
      true if the graph contains edge from n1 to n2.
    • isConnectedInDirection

      public abstract boolean isConnectedInDirection(N n1, E edgeValue, N n2)
      Checks whether two nodes in the graph are connected via a directed edge with the given value.
      Parameters:
      n1 - Node 1.
      edgeValue - edge value tag
      n2 - Node 2.
      Returns:
      true if the edge exists.
    • isConnected

      public boolean isConnected(N n1, N n2)
      Description copied from class: Graph
      Checks whether two nodes in the graph are connected.
      Specified by:
      isConnected in class Graph<N,E>
      Parameters:
      n1 - Node 1.
      n2 - Node 2.
      Returns:
      true if the two nodes are connected.
    • isConnected

      public boolean isConnected(N n1, E e, N n2)
      Description copied from class: Graph
      Checks whether two nodes in the graph are connected by the given edge type.
      Specified by:
      isConnected in class Graph<N,E>
      Parameters:
      n1 - Node 1.
      e - The edge type.
      n2 - Node 2.