Class GraphReachability<N,E>
- java.lang.Object
-
- com.google.javascript.jscomp.graph.GraphReachability<N,E>
-
- Type Parameters:
N- The type of data that the graph node holds.E- The type of data that the graph edge holds.
- All Implemented Interfaces:
FixedPointGraphTraversal.EdgeCallback<N,E>
public final class GraphReachability<N,E> extends java.lang.Object implements FixedPointGraphTraversal.EdgeCallback<N,E>
Computes all the reachable nodes. Upon execution ofcompute(Object), the graph nodes will be annotated withREACHABLEif it is reachable from the specified entry node.- See Also:
Annotatable.getAnnotation()
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classGraphReachability.EdgeTuple<N,E>Represents a Source Node and an Edge.
-
Field Summary
Fields Modifier and Type Field Description static AnnotationREACHABLE
-
Constructor Summary
Constructors Constructor Description GraphReachability(DiGraph<N,E> graph)GraphReachability(DiGraph<N,E> graph, com.google.common.base.Predicate<GraphReachability.EdgeTuple<N,E>> edgePredicate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcompute(N entry)voidrecompute(N reachableNode)booleantraverseEdge(N source, E e, N destination)Update the state of the destination node when the given edge is traversed.
-
-
-
Field Detail
-
REACHABLE
public static final Annotation REACHABLE
-
-
Constructor Detail
-
GraphReachability
public GraphReachability(DiGraph<N,E> graph, com.google.common.base.Predicate<GraphReachability.EdgeTuple<N,E>> edgePredicate)
- Parameters:
graph- The graph.edgePredicate- Given the predecessor P of the a node S and the edge coming from P to S, this predicate should return true if S is reachable from P using the edge.
-
-
Method Detail
-
compute
public void compute(N entry)
-
recompute
public void recompute(N reachableNode)
-
traverseEdge
public boolean traverseEdge(N source, E e, N destination)
Description copied from interface:FixedPointGraphTraversal.EdgeCallbackUpdate the state of the destination node when the given edge is traversed.Recall that depending on the direction of the traversal,
sourceanddestinationmay be swapped compared to the orientation of the edge in the graph. In either case, only thedestinationparameter may be mutated.- Specified by:
traverseEdgein interfaceFixedPointGraphTraversal.EdgeCallback<N,E>- Parameters:
source- The start node.e- The edge.destination- The end node.- Returns:
- Whether the state of the destination node changed.
-
-