public abstract class Graphs extends Object
Constructor and Description |
---|
Graphs() |
Modifier and Type | Method and Description |
---|---|
static <V,E> boolean |
addAllEdges(Graph<? super V,? super E> destination,
Graph<V,E> source,
Collection<? extends E> edges)
Adds a subset of the edges of the specified source graph to the specified
destination graph.
|
static <V,E> boolean |
addAllVertices(Graph<? super V,? super E> destination,
Collection<? extends V> vertices)
Adds all of the specified vertices to the destination graph.
|
static <V,E> E |
addEdge(Graph<V,E> g,
V sourceVertex,
V targetVertex,
double weight)
Creates a new edge and adds it to the specified graph similarly to the
Graph.addEdge(Object, Object) method. |
static <V,E> boolean |
addEdgeWithVertices(Graph<V,E> targetGraph,
Graph<V,E> sourceGraph,
E edge)
Adds the specified edge to the graph, including its vertices if not
already included.
|
static <V,E> E |
addEdgeWithVertices(Graph<V,E> g,
V sourceVertex,
V targetVertex)
Adds the specified source and target vertices to the graph, if not
already included, and creates a new edge and adds it to the specified
graph similarly to the
Graph.addEdge(Object, Object) method. |
static <V,E> E |
addEdgeWithVertices(Graph<V,E> g,
V sourceVertex,
V targetVertex,
double weight)
Adds the specified source and target vertices to the graph, if not
already included, and creates a new weighted edge and adds it to the
specified graph similarly to the
Graph.addEdge(Object, Object)
method. |
static <V,E> boolean |
addGraph(Graph<? super V,? super E> destination,
Graph<V,E> source)
Adds all the vertices and all the edges of the specified source graph to
the specified destination graph.
|
static <V,E> void |
addGraphReversed(DirectedGraph<? super V,? super E> destination,
DirectedGraph<V,E> source)
Adds all the vertices and all the edges of the specified source digraph
to the specified destination digraph, reversing all of the edges.
|
static <V,E> V |
getOppositeVertex(Graph<V,E> g,
E e,
V v)
Gets the vertex opposite another vertex across an edge.
|
static <V,E> List<V> |
getPathVertexList(GraphPath<V,E> path)
Gets the list of vertices visited by a path.
|
static <V,E> List<V> |
neighborListOf(Graph<V,E> g,
V vertex)
Returns a list of vertices that are the neighbors of a specified vertex.
|
static <V,E> List<V> |
predecessorListOf(DirectedGraph<V,E> g,
V vertex)
Returns a list of vertices that are the direct predecessors of a
specified vertex.
|
static <V,E> List<V> |
successorListOf(DirectedGraph<V,E> g,
V vertex)
Returns a list of vertices that are the direct successors of a specified
vertex.
|
static <V,E> boolean |
testIncidence(Graph<V,E> g,
E e,
V v)
Tests whether an edge is incident to a vertex.
|
static <V,E> UndirectedGraph<V,E> |
undirectedGraph(Graph<V,E> g)
Returns an undirected view of the specified graph.
|
public static <V,E> E addEdge(Graph<V,E> g, V sourceVertex, V targetVertex, double weight)
Graph.addEdge(Object, Object)
method.g
- the graph for which the edge to be added.sourceVertex
- source vertex of the edge.targetVertex
- target vertex of the edge.weight
- weight of the edge.
null
.Graph.addEdge(Object, Object)
public static <V,E> E addEdgeWithVertices(Graph<V,E> g, V sourceVertex, V targetVertex)
Graph.addEdge(Object, Object)
method.g
- the graph for which the specified edge to be added.sourceVertex
- source vertex of the edge.targetVertex
- target vertex of the edge.
null
.public static <V,E> boolean addEdgeWithVertices(Graph<V,E> targetGraph, Graph<V,E> sourceGraph, E edge)
targetGraph
- the graph for which the specified edge to be added.sourceGraph
- the graph in which the specified edge is already
presentedge
- edge to addpublic static <V,E> E addEdgeWithVertices(Graph<V,E> g, V sourceVertex, V targetVertex, double weight)
Graph.addEdge(Object, Object)
method.g
- the graph for which the specified edge to be added.sourceVertex
- source vertex of the edge.targetVertex
- target vertex of the edge.weight
- weight of the edge.
null
.public static <V,E> boolean addGraph(Graph<? super V,? super E> destination, Graph<V,E> source)
true
if the destination graph has been modified as a result of this operation,
otherwise it returns false
.
The behavior of this operation is undefined if any of the specified graphs is modified while operation is in progress.
destination
- the graph to which vertices and edges are added.source
- the graph used as source for vertices and edges to add.true
if and only if the destination graph has been
changed as a result of this operation.public static <V,E> void addGraphReversed(DirectedGraph<? super V,? super E> destination, DirectedGraph<V,E> source)
EdgeReversedGraph
instead.
The behavior of this operation is undefined if any of the specified graphs is modified while operation is in progress.
destination
- the graph to which vertices and edges are added.source
- the graph used as source for vertices and edges to add.EdgeReversedGraph
public static <V,E> boolean addAllEdges(Graph<? super V,? super E> destination, Graph<V,E> source, Collection<? extends E> edges)
addEdgeWithVertices(org.jgrapht.Graph<V, E>, V, V)
is used for the transfer, so source vertexes will
be added automatically to the target graph.destination
- the graph to which edges are to be addedsource
- the graph used as a source for edges to addedges
- the edges to be addedpublic static <V,E> boolean addAllVertices(Graph<? super V,? super E> destination, Collection<? extends V> vertices)
Graph.addVertex(Object)
method.destination
- the graph to which edges are to be addedvertices
- the vertices to be added to the graph.NullPointerException
- if the specified vertices contains one or
more null vertices, or if the specified vertex collection is
null.Graph.addVertex(Object)
public static <V,E> List<V> neighborListOf(Graph<V,E> g, V vertex)
g
- the graph to look for neighbors in.vertex
- the vertex to get the neighbors of.public static <V,E> List<V> predecessorListOf(DirectedGraph<V,E> g, V vertex)
g
- the graph to look for predecessors in.vertex
- the vertex to get the predecessors of.public static <V,E> List<V> successorListOf(DirectedGraph<V,E> g, V vertex)
g
- the graph to look for successors in.vertex
- the vertex to get the successors of.public static <V,E> UndirectedGraph<V,E> undirectedGraph(Graph<V,E> g)
g
- the graph for which an undirected view is to be returned.IllegalArgumentException
- if the graph is neither DirectedGraph
nor UndirectedGraph.AsUndirectedGraph
public static <V,E> boolean testIncidence(Graph<V,E> g, E e, V v)
g
- graph containing e and ve
- edge in gv
- vertex in gpublic static <V,E> V getOppositeVertex(Graph<V,E> g, E e, V v)
g
- graph containing e and ve
- edge in gv
- vertex in gCopyright © 2016. All rights reserved.