commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1203527 - /commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/connectedcomponents/Tarjan.java
Date Fri, 18 Nov 2011 08:38:42 GMT
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.



Mime
View raw message