N
- Value type that the graph node stores.E
- Value type that the graph edge stores.public class LinkedDirectedGraph<N,E> extends DiGraph<N,E> implements GraphvizGraph
This implementation favors directed graph operations inherited from
DirectedGraph
.
Operations from Graph
would tends to be slower.
DiGraph.DiGraphEdge<N,E>, DiGraph.DiGraphNode<N,E>
Graph.GraphEdge<N,E>
GraphvizGraph.GraphvizEdge, GraphvizGraph.GraphvizNode
Modifier and Type | Field and Description |
---|---|
protected Map<N,com.google.javascript.jscomp.graph.LinkedDirectedGraph.LinkedDirectedGraphNode<N,E>> |
nodes |
Modifier | Constructor and Description |
---|---|
protected |
LinkedDirectedGraph(boolean useNodeAnnotations,
boolean useEdgeAnnotations) |
Modifier and Type | Method and Description |
---|---|
void |
connect(N srcValue,
E edgeValue,
N destValue)
Connects two nodes in the graph with an edge.
|
static <N,E> LinkedDirectedGraph<N,E> |
create() |
DiGraph.DiGraphNode<N,E> |
createDirectedGraphNode(N nodeValue) |
GraphNode<N,E> |
createNode(N value)
Gets a node from the graph given a value.
|
static <N,E> LinkedDirectedGraph<N,E> |
createWithEdgeAnnotations() |
static <N,E> LinkedDirectedGraph<N,E> |
createWithNodeAnnotations() |
static <N,E> LinkedDirectedGraph<N,E> |
createWithoutAnnotations() |
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.
|
List<DiGraph.DiGraphEdge<N,E>> |
getDirectedGraphEdges(N n1,
N n2) |
DiGraph.DiGraphNode<N,E> |
getDirectedGraphNode(N nodeValue) |
Iterable<DiGraph.DiGraphNode<N,E>> |
getDirectedGraphNodes()
Gets an immutable iterable over all the nodes in the graph.
|
List<DiGraph.DiGraphNode<N,E>> |
getDirectedPredNodes(DiGraph.DiGraphNode<N,E> dNode) |
List<DiGraph.DiGraphNode<N,E>> |
getDirectedPredNodes(N nodeValue) |
List<DiGraph.DiGraphNode<N,E>> |
getDirectedSuccNodes(DiGraph.DiGraphNode<N,E> dNode) |
List<DiGraph.DiGraphNode<N,E>> |
getDirectedSuccNodes(N nodeValue) |
List<DiGraph.DiGraphEdge<N,E>> |
getEdges()
Gets an immutable list of all edges.
|
List<DiGraph.DiGraphEdge<N,E>> |
getEdges(N n1,
N n2)
Retrieves an edge from the graph.
|
Graph.GraphEdge<N,E> |
getFirstEdge(N n1,
N n2)
Retrieves any edge from the graph.
|
List<GraphvizGraph.GraphvizEdge> |
getGraphvizEdges()
Retrieve a list of edges in the graph.
|
List<GraphvizGraph.GraphvizNode> |
getGraphvizNodes()
Retrieve a list of nodes in the graph.
|
List<DiGraph.DiGraphEdge<N,E>> |
getInEdges(N nodeValue)
Gets an immutable list of in edges of the given node.
|
String |
getName()
Name of the graph.
|
List<GraphNode<N,E>> |
getNeighborNodes(N value)
Gets the neighboring nodes.
|
GraphNode<N,E> |
getNode(N nodeValue)
Gets a node from the graph given a value.
|
int |
getNodeDegree(N value)
Gets the degree of a node.
|
Collection<DiGraph.DiGraphNode<N,E>> |
getNodes()
Gets an immutable list of all nodes.
|
List<DiGraph.DiGraphEdge<N,E>> |
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 |
isDirected()
Graph type.
|
SubGraph<N,E> |
newSubGraph()
Returns an empty SubGraph for this Graph.
|
isConnected, isConnected
clearEdgeAnnotations, clearNodeAnnotations, connectIfNotFound, getWeight, hasNode, popEdgeAnnotations, popNodeAnnotations, pushEdgeAnnotations, pushNodeAnnotations
protected LinkedDirectedGraph(boolean useNodeAnnotations, boolean useEdgeAnnotations)
public SubGraph<N,E> newSubGraph()
AdjacencyGraph
newSubGraph
in interface AdjacencyGraph<N,E>
public static <N,E> LinkedDirectedGraph<N,E> createWithoutAnnotations()
public static <N,E> LinkedDirectedGraph<N,E> createWithNodeAnnotations()
public static <N,E> LinkedDirectedGraph<N,E> createWithEdgeAnnotations()
public static <N,E> LinkedDirectedGraph<N,E> create()
public void connect(N srcValue, E edgeValue, N destValue)
Graph
public void disconnect(N n1, N n2)
Graph
disconnect
in class Graph<N,E>
n1
- First node.n2
- Second node.public void disconnectInDirection(N srcValue, N destValue)
DiGraph
disconnectInDirection
in class DiGraph<N,E>
srcValue
- Source node.destValue
- Destination node.public Iterable<DiGraph.DiGraphNode<N,E>> getDirectedGraphNodes()
DiGraph
getDirectedGraphNodes
in class DiGraph<N,E>
public DiGraph.DiGraphNode<N,E> getDirectedGraphNode(N nodeValue)
getDirectedGraphNode
in class DiGraph<N,E>
public GraphNode<N,E> getNode(N nodeValue)
AdjacencyGraph
Object.equals
.getNode
in interface AdjacencyGraph<N,E>
nodeValue
- The node's value.public List<DiGraph.DiGraphEdge<N,E>> getInEdges(N nodeValue)
DiGraph
getInEdges
in class DiGraph<N,E>
public List<DiGraph.DiGraphEdge<N,E>> getOutEdges(N nodeValue)
DiGraph
getOutEdges
in class DiGraph<N,E>
public DiGraph.DiGraphNode<N,E> createDirectedGraphNode(N nodeValue)
createDirectedGraphNode
in class DiGraph<N,E>
public List<DiGraph.DiGraphEdge<N,E>> getEdges(N n1, N n2)
Graph
public Graph.GraphEdge<N,E> getFirstEdge(N n1, N n2)
Graph
getFirstEdge
in class Graph<N,E>
n1
- Node one.n2
- Node two.public GraphNode<N,E> createNode(N value)
Graph
Object.equals
.createNode
in class Graph<N,E>
value
- The node's value.public List<DiGraph.DiGraphEdge<N,E>> getDirectedGraphEdges(N n1, N n2)
getDirectedGraphEdges
in class DiGraph<N,E>
public boolean isConnectedInDirection(N n1, N n2)
DiGraph
isConnectedInDirection
in class DiGraph<N,E>
n1
- Node 1.n2
- Node 2.true
if the graph contains edge from n1 to n2.public boolean isConnectedInDirection(N n1, E edgeValue, N n2)
DiGraph
isConnectedInDirection
in class DiGraph<N,E>
n1
- Node 1.edgeValue
- edge value tagn2
- Node 2.true
if the edge exists.public List<DiGraph.DiGraphNode<N,E>> getDirectedPredNodes(N nodeValue)
getDirectedPredNodes
in class DiGraph<N,E>
public List<DiGraph.DiGraphNode<N,E>> getDirectedSuccNodes(N nodeValue)
getDirectedSuccNodes
in class DiGraph<N,E>
public List<DiGraph.DiGraphNode<N,E>> getDirectedPredNodes(DiGraph.DiGraphNode<N,E> dNode)
getDirectedPredNodes
in class DiGraph<N,E>
public List<DiGraph.DiGraphNode<N,E>> getDirectedSuccNodes(DiGraph.DiGraphNode<N,E> dNode)
getDirectedSuccNodes
in class DiGraph<N,E>
public List<GraphvizGraph.GraphvizEdge> getGraphvizEdges()
GraphvizGraph
getGraphvizEdges
in interface GraphvizGraph
public List<GraphvizGraph.GraphvizNode> getGraphvizNodes()
GraphvizGraph
getGraphvizNodes
in interface GraphvizGraph
public String getName()
GraphvizGraph
getName
in interface GraphvizGraph
public boolean isDirected()
GraphvizGraph
isDirected
in interface GraphvizGraph
public Collection<DiGraph.DiGraphNode<N,E>> getNodes()
Graph
public List<GraphNode<N,E>> getNeighborNodes(N value)
Graph
getNeighborNodes
in class Graph<N,E>
value
- The node's value.public List<DiGraph.DiGraphEdge<N,E>> getEdges()
Graph
Copyright © 2009-2014 Google. All Rights Reserved.