Package org.apache.calcite.util.graph
Class DefaultDirectedGraph<V,E extends DefaultEdge>
- java.lang.Object
-
- org.apache.calcite.util.graph.DefaultDirectedGraph<V,E>
-
- Type Parameters:
V
- Vertex typeE
- Edge type
- All Implemented Interfaces:
DirectedGraph<V,E>
- Direct Known Subclasses:
AttributedDirectedGraph
public class DefaultDirectedGraph<V,E extends DefaultEdge> extends java.lang.Object implements DirectedGraph<V,E>
Default implementation ofDirectedGraph
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
DefaultDirectedGraph.VertexInfo<V,E>
Information about an edge.-
Nested classes/interfaces inherited from interface org.apache.calcite.util.graph.DirectedGraph
DirectedGraph.EdgeFactory<V,E>
-
-
Field Summary
Fields Modifier and Type Field Description (package private) DirectedGraph.EdgeFactory<V,E>
edgeFactory
(package private) java.util.Set<E>
edges
(package private) java.util.Map<V,DefaultDirectedGraph.VertexInfo<V,E>>
vertexMap
-
Constructor Summary
Constructors Constructor Description DefaultDirectedGraph(DirectedGraph.EdgeFactory<V,E> edgeFactory)
Creates a graph.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description E
addEdge(V vertex, V targetVertex)
Adds an edge to this graph.boolean
addVertex(V vertex)
Adds a vertex to this graph.static <V> DefaultDirectedGraph<V,DefaultEdge>
create()
static <V,E extends DefaultEdge>
DefaultDirectedGraph<V,E>create(DirectedGraph.EdgeFactory<V,E> edgeFactory)
java.util.Set<E>
edgeSet()
E
getEdge(V source, V target)
java.util.List<E>
getInwardEdges(V target)
java.util.List<E>
getOutwardEdges(V source)
void
removeAllVertices(java.util.Collection<V> collection)
boolean
removeEdge(V source, V target)
(package private) V
source(E edge)
(package private) V
target(E edge)
java.lang.String
toString()
private java.lang.String
toString(com.google.common.collect.Ordering<V> vertexOrdering, com.google.common.collect.Ordering<E> edgeOrdering)
Returns the string representation of this graph, using the given orderings to ensure that the output order of vertices and edges is deterministic.java.lang.String
toStringUnordered()
java.util.Set<V>
vertexSet()
-
-
-
Field Detail
-
edges
final java.util.Set<E extends DefaultEdge> edges
-
vertexMap
final java.util.Map<V,DefaultDirectedGraph.VertexInfo<V,E extends DefaultEdge>> vertexMap
-
edgeFactory
final DirectedGraph.EdgeFactory<V,E extends DefaultEdge> edgeFactory
-
-
Constructor Detail
-
DefaultDirectedGraph
public DefaultDirectedGraph(DirectedGraph.EdgeFactory<V,E> edgeFactory)
Creates a graph.
-
-
Method Detail
-
create
public static <V> DefaultDirectedGraph<V,DefaultEdge> create()
-
create
public static <V,E extends DefaultEdge> DefaultDirectedGraph<V,E> create(DirectedGraph.EdgeFactory<V,E> edgeFactory)
-
toStringUnordered
public java.lang.String toStringUnordered()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
toString
private java.lang.String toString(com.google.common.collect.Ordering<V> vertexOrdering, com.google.common.collect.Ordering<E> edgeOrdering)
Returns the string representation of this graph, using the given orderings to ensure that the output order of vertices and edges is deterministic.
-
addVertex
public boolean addVertex(V vertex)
Description copied from interface:DirectedGraph
Adds a vertex to this graph.- Specified by:
addVertex
in interfaceDirectedGraph<V,E extends DefaultEdge>
- Parameters:
vertex
- Vertex- Returns:
- Whether vertex was added
-
edgeSet
public java.util.Set<E> edgeSet()
- Specified by:
edgeSet
in interfaceDirectedGraph<V,E extends DefaultEdge>
-
addEdge
public E addEdge(V vertex, V targetVertex)
Description copied from interface:DirectedGraph
Adds an edge to this graph.- Specified by:
addEdge
in interfaceDirectedGraph<V,E extends DefaultEdge>
- Parameters:
vertex
- Source vertextargetVertex
- Target vertex- Returns:
- New edge, if added, otherwise null
-
getEdge
public E getEdge(V source, V target)
- Specified by:
getEdge
in interfaceDirectedGraph<V,E extends DefaultEdge>
-
removeEdge
public boolean removeEdge(V source, V target)
- Specified by:
removeEdge
in interfaceDirectedGraph<V,E extends DefaultEdge>
-
vertexSet
public java.util.Set<V> vertexSet()
- Specified by:
vertexSet
in interfaceDirectedGraph<V,E extends DefaultEdge>
-
removeAllVertices
public void removeAllVertices(java.util.Collection<V> collection)
- Specified by:
removeAllVertices
in interfaceDirectedGraph<V,E extends DefaultEdge>
-
getOutwardEdges
public java.util.List<E> getOutwardEdges(V source)
- Specified by:
getOutwardEdges
in interfaceDirectedGraph<V,E extends DefaultEdge>
-
getInwardEdges
public java.util.List<E> getInwardEdges(V target)
- Specified by:
getInwardEdges
in interfaceDirectedGraph<V,E extends DefaultEdge>
-
-