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.
Modifier and Type | Class and Description |
---|---|
static class |
LinkedDirectedGraph.LinkedDirectedGraphNode<N,E>
A directed graph node that stores outgoing edges and incoming edges as an
list within the node itself.
|
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,LinkedDirectedGraph.LinkedDirectedGraphNode<N,E>> |
nodes |
Modifier | Constructor and Description |
---|---|
protected |
LinkedDirectedGraph(boolean useNodeAnnotations,
boolean useEdgeAnnotations) |
Modifier and Type | Method and Description |
---|---|
void |
connect(DiGraph.DiGraphNode<N,E> src,
E edgeValue,
DiGraph.DiGraphNode<N,E> dest)
DiGraphNode look ups can be expensive for a large graph operation, prefer this
method if you have the DiGraphNode available.
|
void |
connect(N srcValue,
E edgeValue,
N destValue)
Connects two nodes in the graph with an edge.
|
void |
connectIfNotConnectedInDirection(N srcValue,
E edgeValue,
N destValue)
DiGraphNode look ups can be expensive for a large graph operation, prefer this
method if you have the DiGraphNode available.
|
static <N,E> LinkedDirectedGraph<N,E> |
create() |
LinkedDirectedGraph.LinkedDirectedGraphNode<N,E> |
createDirectedGraphNode(N nodeValue) |
DiGraph.DiGraphNode<N,E> |
createNode(N value)
Gets a node from the graph given a value.
|
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(DiGraph.DiGraphNode<N,E> dNode1,
com.google.common.base.Predicate<E> edgeMatcher,
DiGraph.DiGraphNode<N,E> dNode2)
DiGraphNode look ups can be expensive for a large graph operation, prefer this
method if you have the DiGraphNodes available.
|
boolean |
isConnectedInDirection(N n1,
E edgeValue,
N n2)
DiGraphNode look ups can be expensive for a large graph operation, prefer the
version below that takes DiGraphNodes, if you have them available.
|
boolean |
isConnectedInDirection(N n1,
N n2)
DiGraphNode look ups can be expensive for a large graph operation, prefer the
version below that takes DiGraphNodes, if you have them available.
|
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 final Map<N,LinkedDirectedGraph.LinkedDirectedGraphNode<N,E>> nodes
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> create()
public void connect(N srcValue, E edgeValue, N destValue)
Graph
public void connect(DiGraph.DiGraphNode<N,E> src, E edgeValue, DiGraph.DiGraphNode<N,E> dest)
public void connectIfNotConnectedInDirection(N srcValue, E edgeValue, N destValue)
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 LinkedDirectedGraph.LinkedDirectedGraphNode<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 DiGraph.DiGraphNode<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)
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)
isConnectedInDirection
in class DiGraph<N,E>
n1
- Node 1.edgeValue
- edge value tagn2
- Node 2.true
if the edge exists.public boolean isConnectedInDirection(DiGraph.DiGraphNode<N,E> dNode1, com.google.common.base.Predicate<E> edgeMatcher, DiGraph.DiGraphNode<N,E> dNode2)
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-2017 Google. All Rights Reserved.