You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by si...@apache.org on 2011/11/18 09:38:42 UTC

svn commit: r1203527 - /commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/connectedcomponents/Tarjan.java

Author: simonetripodi
Date: Fri Nov 18 08:38:41 2011
New Revision: 1203527

URL: http://svn.apache.org/viewvc?rev=1203527&view=rev
Log:
added simple method just to check if the input graph has a strongly connected component

Modified:
    commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/connectedcomponents/Tarjan.java

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/connectedcomponents/Tarjan.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/connectedcomponents/Tarjan.java?rev=1203527&r1=1203526&r2=1203527&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/connectedcomponents/Tarjan.java (original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/connectedcomponents/Tarjan.java Fri Nov 18 08:38:41 2011
@@ -39,6 +39,19 @@ public final class Tarjan
 {
 
     /**
+     * Applies the classical Tarjan's algorithm checking if there is a strongly connected component.
+     *
+     * @param <V> the Graph vertices type.
+     * @param <E> the Graph edges type.
+     * @param graph the Graph which strongly connected component has to be verified.
+     * @return true, if the input graph has a strongly connected component, false otherwise.
+     */
+    public static <V extends Vertex, E extends Edge> boolean hasStronglyConnectedComponent( DirectedGraph<V, E> graph )
+    {
+        return !getStronglyConnectedComponent( graph ).isEmpty();
+    }
+
+    /**
      * Applies the classical Tarjan's algorithm to find the strongly connected components, if exist.
      *
      * @param <V> the Graph vertices type.