public final class GraphUtils
extends java.lang.Object
| Modifier and Type | Method and Description | 
|---|---|
| static <V> java.util.List<Edge<V>> | acyclicTransitiveReduction(DirectedGraph<V> acyclicGraph)For a given acyclic graph this method returns a list of edges that can be
 removed to obtain a transitive reduction of the given graph. | 
| static <V> DirectedGraph<V> | completeGraph(java.util.Set<V> vertices)Returns complete graph over given set of vertices. | 
| static <V> java.util.List<java.util.List<V>> | computeSCC(DirectedGraph<V> graph)Computes strongly-connected components. | 
| static <V> java.util.List<V> | getCycle(DirectedGraph<V> graph)Returns a list of vertices forming a cycle or  nullif the
 graph is acyclic. | 
| static <V> java.util.Set<V> | getVerticesInCycles(DirectedGraph<V> graph)Returns a set of all vertices that take part in a cycle. | 
| static <V> java.util.List<V> | internalTopSort(DirectedGraph<V> graph)Returns topological sort of given directed graph or  nullif the graph is
 not acyclic. | 
| static boolean | isAcyclic(DirectedGraph<?> graph)Returns true if given graph is acyclic. | 
| static <V> DirectedGraph<V> | reverse(DirectedGraph<V> graph)Returns reverse of given graph (all edges are reversed). | 
| static <V> DirectedGraph<V> | subgraph(DirectedGraph<V> graph,
        java.util.Set<V> vertices)Returns new instance of  DirectedGraphinduced by given set of
 vertices on given graph. | 
| static <V> java.util.List<V> | topologicalSort(DirectedGraph<V> graph)Returns topological sort of given acyclic directed graph. | 
| static void | transitiveClosure(DirectedGraph<?> graph)Adds edges to a given graph to create a transitive closure. | 
| static <V> java.util.Set<V> | transitiveClosure(DirectedGraph<V> graph,
                 java.util.Set<? extends V> vertices)Returns transitive closure of given vertices on given graph. | 
public static <V> DirectedGraph<V> subgraph(DirectedGraph<V> graph, java.util.Set<V> vertices)
DirectedGraph induced by given set of
 vertices on given graph. Given vertices must form a subset of the graph
 vertices.V - type of graph vertexvertices - set of verticesgraph - directed graphjava.lang.NullPointerException - if any argument is nulljava.lang.IllegalArgumentException - if given vertices are not a subset of this graph verticespublic static <V> DirectedGraph<V> completeGraph(java.util.Set<V> vertices)
V - type of vertexvertices - set of verticesjava.lang.NullPointerException - if argument vertices is nullpublic static <V> java.util.Set<V> transitiveClosure(DirectedGraph<V> graph, java.util.Set<? extends V> vertices)
V - type of vertexgraph - directed graphvertices - set of verticesjava.lang.NullPointerException - if any argument is nulljava.lang.IllegalArgumentException - if given vertices are not a subset of this graph verticespublic static void transitiveClosure(DirectedGraph<?> graph)
graph - public static <V> DirectedGraph<V> reverse(DirectedGraph<V> graph)
V - type of vertexgraph - directed graphpublic static <V> java.util.List<V> topologicalSort(DirectedGraph<V> graph)
V - type of vertexgraph - acyclic directed graphjava.lang.IllegalArgumentException - if given graph is not acyclicpublic static <V> java.util.List<V> internalTopSort(DirectedGraph<V> graph)
null if the graph is
 not acyclic.
 IMPORTANT: the method modifies the given graph.
V - type of vertexgraph - directed graph (will be modified by the method)public static boolean isAcyclic(DirectedGraph<?> graph)
graph - directed graphpublic static <V> java.util.List<V> getCycle(DirectedGraph<V> graph)
null if the
 graph is acyclic. The algorithm finds only one cycle, not all cycles.V - graph - null if the
         graph is acyclicpublic static <V> java.util.List<java.util.List<V>> computeSCC(DirectedGraph<V> graph)
V - graph - public static <V> java.util.Set<V> getVerticesInCycles(DirectedGraph<V> graph)
V - graph - public static <V> java.util.List<Edge<V>> acyclicTransitiveReduction(DirectedGraph<V> acyclicGraph)
V - acyclicGraph - Copyright © 2007-2020 Whitestein Technologies. All Rights Reserved.