Class LinkedDirectedGraph<N,E>
java.lang.Object
com.google.javascript.jscomp.graph.Graph<N,E>
com.google.javascript.jscomp.graph.DiGraph<N,E>
com.google.javascript.jscomp.graph.LinkedDirectedGraph<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> GraphvizGraph
A directed graph using linked list within nodes to store edge information.
This implementation favors directed graph operations inherited from
DirectedGraph
.
Operations from Graph
would tends to be slower.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.google.javascript.jscomp.graph.DiGraph
DiGraph.DiGraphEdge<N,
E>, DiGraph.DiGraphNode<N, E> Nested classes/interfaces inherited from class com.google.javascript.jscomp.graph.Graph
Graph.GraphEdge<N,
E> Nested classes/interfaces inherited from interface com.google.javascript.jscomp.graph.GraphvizGraph
GraphvizGraph.GraphvizEdge, GraphvizGraph.GraphvizNode
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
LinkedDirectedGraph
(boolean useNodeAnnotations, boolean useEdgeAnnotations) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Connects two nodes in the graph with an edge.static <N,
E> LinkedDirectedGraph<N, E> create()
createDirectedGraphNode
(N nodeValue) createNode
(N value) Gets a node from the graph given a value.static <N,
E> LinkedDirectedGraph<N, E> static <N,
E> LinkedDirectedGraph<N, E> static <N,
E> LinkedDirectedGraph<N, E> void
disconnect
(N n1, N n2) Disconnects two nodes in the graph by removing all edges between them.void
disconnectInDirection
(N srcValue, N destValue) Disconnects all edges from n1 to n2.getDirectedGraphEdges
(N n1, N n2) getDirectedGraphNode
(N nodeValue) Gets an immutable iterable over all the nodes in the graph.getDirectedPredNodes
(DiGraph.DiGraphNode<N, E> dNode) getDirectedPredNodes
(N nodeValue) getDirectedSuccNodes
(DiGraph.DiGraphNode<N, E> dNode) getDirectedSuccNodes
(N nodeValue) getEdges()
Gets an immutable list of all edges.Retrieves an edge from the graph.getFirstEdge
(N n1, N n2) Retrieves any edge from the graph.Retrieve a list of edges in the graph.Retrieve a list of nodes in the graph.getInEdges
(N nodeValue) Gets an immutable list of in edges of the given node.getName()
Name of the graph.getNeighborNodes
(DiGraph.DiGraphNode<N, E> node) getNeighborNodes
(N value) Gets the neighboring nodes.getNeighborNodesIterator
(N value) Gets a node from the graph given a value.int
getNodeDegree
(N value) Gets the degree of a node.getNodes()
Gets an immutable list of all nodes.getOutEdges
(N nodeValue) Gets an immutable list of out edges of the given node.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.boolean
isConnectedInDirection
(N n1, N n2) Checks whether two nodes in the graph are connected via a directed edge.boolean
Graph type.Returns an empty SubGraph for this Graph.Methods inherited from class com.google.javascript.jscomp.graph.DiGraph
isConnected, isConnected
Methods inherited from class com.google.javascript.jscomp.graph.Graph
clearEdgeAnnotations, clearNodeAnnotations, connectIfNotFound, getWeight, hasNode, popEdgeAnnotations, popNodeAnnotations, pushEdgeAnnotations, pushNodeAnnotations
-
Field Details
-
nodes
-
-
Constructor Details
-
LinkedDirectedGraph
protected LinkedDirectedGraph(boolean useNodeAnnotations, boolean useEdgeAnnotations)
-
-
Method Details
-
newSubGraph
Description copied from interface:AdjacencyGraph
Returns an empty SubGraph for this Graph.- Specified by:
newSubGraph
in interfaceAdjacencyGraph<N,
E>
-
createWithoutAnnotations
-
createWithNodeAnnotations
-
createWithEdgeAnnotations
-
create
-
connect
Description copied from class:Graph
Connects two nodes in the graph with an edge. -
disconnect
Description copied from class:Graph
Disconnects two nodes in the graph by removing all edges between them.- Specified by:
disconnect
in classGraph<N,
E> - Parameters:
n1
- First node.n2
- Second node.
-
disconnectInDirection
Description copied from class:DiGraph
Disconnects all edges from n1 to n2.- Specified by:
disconnectInDirection
in classDiGraph<N,
E> - Parameters:
srcValue
- Source node.destValue
- Destination node.
-
getDirectedGraphNodes
Description copied from class:DiGraph
Gets an immutable iterable over all the nodes in the graph.- Specified by:
getDirectedGraphNodes
in classDiGraph<N,
E>
-
getDirectedGraphNode
- Specified by:
getDirectedGraphNode
in classDiGraph<N,
E>
-
getNode
Description copied from interface:AdjacencyGraph
Gets a node from the graph given a value. Values equality are compared usingObject.equals
.- Specified by:
getNode
in interfaceAdjacencyGraph<N,
E> - Parameters:
nodeValue
- The node's value.- Returns:
- The corresponding node in the graph, null if there value has no corresponding node.
-
getInEdges
Description copied from class:DiGraph
Gets an immutable list of in edges of the given node.- Specified by:
getInEdges
in classDiGraph<N,
E>
-
getOutEdges
Description copied from class:DiGraph
Gets an immutable list of out edges of the given node.- Specified by:
getOutEdges
in classDiGraph<N,
E>
-
createDirectedGraphNode
- Specified by:
createDirectedGraphNode
in classDiGraph<N,
E>
-
getEdges
Description copied from class:Graph
Retrieves an edge from the graph. -
getFirstEdge
Description copied from class:Graph
Retrieves any edge from the graph.- Specified by:
getFirstEdge
in classGraph<N,
E> - Parameters:
n1
- Node one.n2
- Node two.- Returns:
- The first edges between those two values in the graph. null if there are none.
-
createNode
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 usingObject.equals
.- Specified by:
createNode
in classGraph<N,
E> - Parameters:
value
- The node's value.- Returns:
- The corresponding node in the graph.
-
getDirectedGraphEdges
- Specified by:
getDirectedGraphEdges
in classDiGraph<N,
E>
-
isConnectedInDirection
Description copied from class:DiGraph
Checks whether two nodes in the graph are connected via a directed edge.- Specified by:
isConnectedInDirection
in classDiGraph<N,
E> - Parameters:
n1
- Node 1.n2
- Node 2.- Returns:
true
if the graph contains edge from n1 to n2.
-
isConnectedInDirection
Description copied from class:DiGraph
Checks whether two nodes in the graph are connected via a directed edge with the given value.- Specified by:
isConnectedInDirection
in classDiGraph<N,
E> - Parameters:
n1
- Node 1.edgeValue
- edge value tagn2
- Node 2.- Returns:
true
if the edge exists.
-
getDirectedPredNodes
- Specified by:
getDirectedPredNodes
in classDiGraph<N,
E>
-
getDirectedSuccNodes
- Specified by:
getDirectedSuccNodes
in classDiGraph<N,
E>
-
getDirectedPredNodes
- Specified by:
getDirectedPredNodes
in classDiGraph<N,
E>
-
getDirectedSuccNodes
- Specified by:
getDirectedSuccNodes
in classDiGraph<N,
E>
-
getGraphvizEdges
Description copied from interface:GraphvizGraph
Retrieve a list of edges in the graph.- Specified by:
getGraphvizEdges
in interfaceGraphvizGraph
- Returns:
- A list of edges in the graph.
-
getGraphvizNodes
Description copied from interface:GraphvizGraph
Retrieve a list of nodes in the graph.- Specified by:
getGraphvizNodes
in interfaceGraphvizGraph
- Returns:
- A list of nodes in the graph.
-
getName
Description copied from interface:GraphvizGraph
Name of the graph.- Specified by:
getName
in interfaceGraphvizGraph
- Returns:
- Name of the graph.
-
isDirected
public boolean isDirected()Description copied from interface:GraphvizGraph
Graph type.- Specified by:
isDirected
in interfaceGraphvizGraph
- Returns:
- True if the graph is a directed graph.
-
getNodes
Description copied from class:Graph
Gets an immutable list of all nodes. -
getNeighborNodes
Description copied from class:Graph
Gets the neighboring nodes.- Specified by:
getNeighborNodes
in classGraph<N,
E> - Parameters:
value
- The node's value.- Returns:
- A list of neighboring nodes.
-
getNeighborNodes
-
getNeighborNodesIterator
- Specified by:
getNeighborNodesIterator
in classGraph<N,
E>
-
getEdges
Description copied from class:Graph
Gets an immutable list of all edges. -
getNodeDegree
Description copied from class:Graph
Gets the degree of a node.- Specified by:
getNodeDegree
in classGraph<N,
E> - Parameters:
value
- The node's value.- Returns:
- The degree of the node.
-