public final class Graphs
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static <T,E extends DirectedEdge<T,E>> |
componentMapping(int vertices,
java.lang.Iterable<E> edges)
Returns an array representing a connected component mapping.
|
static int[] |
componentMapping(int vertices,
java.util.List<java.util.List<java.lang.Integer>> components)
Creates an array representing a connected component mapping.
|
static <T,E extends DirectedEdge<T,E>> |
components(int vertices,
java.lang.Iterable<E> edges)
Takes a graph specified by a number of vertices and an
Iterable of edges and returns a List
of List of Integer, where the i-th List contains the indices of all vertices that
belong to the i-th connected component. |
static <T,S,E extends DirectedEdge<T,E> & java.lang.Comparable<? super E>,D extends DirectedEdge<S,D>> |
contract(int vertices,
java.lang.Iterable<D> span,
java.lang.Iterable<E> edges)
Contracts a graph specified by the number of vertices and an
Iterable of edges along the edges
given by the Iterable span. |
static <T,E extends DirectedEdge<T,E> & java.lang.Comparable<? super E>> |
flatten(EdgeList<ContractedEdge<T,ContractedEdge<T,E>>> list)
Takes an
EdgeList of at least doubly contracted edges and removes the second-outermost layer of contracted edges |
static <T,E extends DirectedEdge<T,E> & java.lang.Comparable<? super E>> |
flatten(Graph<ContractedEdge<T,ContractedEdge<T,E>>> graph)
Takes a
Graph of at least doubly contracted edges and removes the second-outermost layer of contracted edges |
static <T,E extends DirectedEdge<T,E> & java.lang.Comparable<? super E>> |
lightestEdgePerVertex(int vertices,
java.lang.Iterable<E> edges)
Takes a graph specified by the number of vertices and an
Iterable of edges. |
static <T,E extends DirectedEdge<T,E> & java.lang.Comparable<? super E>> |
removeDuplicates(int vertices,
java.lang.Iterable<E> edges)
Removes multiple edges between two vertices.
|
static <T,E extends DirectedEdge<T,E> & java.lang.Comparable<? super E>> |
renameVertices(java.lang.Iterable<E> edges)
Takes an
Iterable of edges and renames the vertices, so that all vertex indices
are between 0 and n - 1 where n is the number of vertices |
static <T,E extends DirectedEdge<T,E>> |
sortEdges(int vertices,
java.lang.Iterable<E> edges)
Takes a graph specified by the number of vertices and an
Iterable of edges and returns an
EdgeList containing all edges in a sorted manner. |
public static <T,E extends DirectedEdge<T,E>> int[] componentMapping(int vertices, java.lang.Iterable<E> edges)
T - the weight type of the edges in the graphE - the edge type of the edges in the graphvertices - the number of vertices in the graphedges - an Iterable of all edges in the graphpublic static int[] componentMapping(int vertices,
java.util.List<java.util.List<java.lang.Integer>> components)
vertices - the number of vertices in the graphcomponents - a List of List of Integer where the i-th List contains the indices of all
vertices that belong to the i-th componentpublic static <T,E extends DirectedEdge<T,E>> java.util.List<java.util.List<java.lang.Integer>> components(int vertices, java.lang.Iterable<E> edges)
Iterable of edges and returns a List
of List of Integer, where the i-th List contains the indices of all vertices that
belong to the i-th connected component.T - the weight type of the edges of the graphE - the edge type of the edges of the graphvertices - the number of vertices of the graphedges - an Iterable of edges of the graphList of List of Integer representing the connected components of the graph
as described abovepublic static <T,E extends DirectedEdge<T,E>> EdgeList<E> sortEdges(int vertices, java.lang.Iterable<E> edges)
Iterable of edges and returns an
EdgeList containing all edges in a sorted manner.T - the weight type of the edges of the graphE - the edge type of the edges of the graphvertices - the number of vertices in the graphedges - an Iterable of edges in the graphEdgeList containing all edges of the original graph, but sortedpublic static <T,E extends DirectedEdge<T,E> & java.lang.Comparable<? super E>> EdgeList<E> removeDuplicates(int vertices, java.lang.Iterable<E> edges)
T - the weight type of the edges of the graphE - the edge type of the edges of the graphvertices - the number of vertices of the graphedges - an Iterable of edges of the graphEdgeList containing no duplicates of edgespublic static <T,E extends DirectedEdge<T,E> & java.lang.Comparable<? super E>> Graph<RenamedEdge<T,E>> renameVertices(java.lang.Iterable<E> edges)
Iterable of edges and renames the vertices, so that all vertex indices
are between 0 and n - 1 where n is the number of verticesT - the weight type of the edges of the graphE - the edge type of the edges of the graphedges - the Iterable whose vertices shall be renamedGraph representing the graph but with renamed edgespublic static <T,E extends DirectedEdge<T,E> & java.lang.Comparable<? super E>> java.util.Set<E> lightestEdgePerVertex(int vertices, java.lang.Iterable<E> edges)
Iterable of edges.
For each vertex we take the outgoing edge with smallest weight and return a Set of all of these edgesT - the weight type of the edges of the graphE - the edge type of the edges of the graphvertices - the number of vertices of the graphedges - an Iterable of edges of the graphSet containing only the lightest edge per vertexpublic static <T,S,E extends DirectedEdge<T,E> & java.lang.Comparable<? super E>,D extends DirectedEdge<S,D>> Graph<ContractedEdge<T,E>> contract(int vertices, java.lang.Iterable<D> span, java.lang.Iterable<E> edges)
Iterable of edges along the edges
given by the Iterable span. Each group of vertices that is connected by some of the edges of span
will be replaced by a single vertex in the contracted graph.T - the weight type of the edges of the graphE - the edge type of the edges of the graphS - the weight type of the edges along which we contractD - the edge type of the edges along which we contractvertices - the number of vertices in the graphspan - an Iterable along which the graph shall be contractededges - an Iterable of edges of the graphGraphpublic static <T,E extends DirectedEdge<T,E> & java.lang.Comparable<? super E>> EdgeList<ContractedEdge<T,E>> flatten(EdgeList<ContractedEdge<T,ContractedEdge<T,E>>> list)
EdgeList of at least doubly contracted edges and removes the second-outermost layer of contracted edgespublic static <T,E extends DirectedEdge<T,E> & java.lang.Comparable<? super E>> Graph<ContractedEdge<T,E>> flatten(Graph<ContractedEdge<T,ContractedEdge<T,E>>> graph)
Graph of at least doubly contracted edges and removes the second-outermost layer of contracted edges