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 2013/05/28 17:00:33 UTC
svn commit: r1486948 [4/5] - in
/commons/sandbox/graph/branches/modularization: ./ api/ api/src/
api/src/main/ api/src/main/java/ api/src/main/java/org/
api/src/main/java/org/apache/ api/src/main/java/org/apache/commons/
api/src/main/java/org/apache/co...
Copied: commons/sandbox/graph/branches/modularization/model/src/test/java/org/apache/commons/graph/model/GraphSerializationTestCase.java (from r1486530, commons/sandbox/graph/branches/modularization/src/test/java/org/apache/commons/graph/model/GraphSerializationTestCase.java)
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/model/src/test/java/org/apache/commons/graph/model/GraphSerializationTestCase.java?p2=commons/sandbox/graph/branches/modularization/model/src/test/java/org/apache/commons/graph/model/GraphSerializationTestCase.java&p1=commons/sandbox/graph/branches/modularization/src/test/java/org/apache/commons/graph/model/GraphSerializationTestCase.java&r1=1486530&r2=1486948&rev=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/src/test/java/org/apache/commons/graph/model/GraphSerializationTestCase.java (original)
+++ commons/sandbox/graph/branches/modularization/model/src/test/java/org/apache/commons/graph/model/GraphSerializationTestCase.java Tue May 28 15:00:27 2013
@@ -20,10 +20,8 @@ package org.apache.commons.graph.model;
*/
import static junit.framework.Assert.assertEquals;
-import static org.apache.commons.graph.CommonsGraph.newDirectedMutableGraph;
-import static org.apache.commons.graph.CommonsGraph.newUndirectedMutableGraph;
-import static org.apache.commons.graph.CommonsGraph.populate;
-import static org.apache.commons.graph.CommonsGraph.synchronize;
+import static org.apache.commons.graph.Graphs.populate;
+import static org.apache.commons.graph.Graphs.synchronize;
import java.io.File;
import java.io.FileInputStream;
@@ -38,7 +36,11 @@ import org.apache.commons.graph.Graph;
import org.apache.commons.graph.MutableGraph;
import org.apache.commons.graph.builder.AbstractGraphConnection;
import org.apache.commons.graph.builder.GraphConnection;
-import org.apache.commons.graph.weight.primitive.DoubleWeightBaseOperations;
+import org.apache.commons.graph.math.monoid.primitive.DoubleWeightBaseOperations;
+import org.apache.commons.graph.model.labeled.BaseLabeledEdge;
+import org.apache.commons.graph.model.labeled.BaseLabeledVertex;
+import org.apache.commons.graph.model.labeled.BaseLabeledWeightedEdge;
+import org.apache.commons.graph.model.labeled.BaseWeightedEdge;
import org.junit.After;
import org.junit.Test;
@@ -64,7 +66,9 @@ public class GraphSerializationTestCase
public void serializeUndirectedGraph()
throws Exception
{
- MutableGraph<BaseLabeledVertex, BaseLabeledEdge> g = newUndirectedMutableGraph( buildGraphConnections() );
+ MutableGraph<BaseLabeledVertex, BaseLabeledEdge> g =
+ populate( new UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledEdge>() )
+ .withConnections( buildGraphConnections() );
checkSerialization( g );
}
@@ -73,7 +77,9 @@ public class GraphSerializationTestCase
public void serializeDirectedGraph()
throws Exception
{
- MutableGraph<BaseLabeledVertex, BaseLabeledEdge> g = newDirectedMutableGraph( buildGraphConnections() );
+ MutableGraph<BaseLabeledVertex, BaseLabeledEdge> g =
+ populate( new UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledEdge>() )
+ .withConnections( buildGraphConnections() );
checkSerialization( g );
}
@@ -83,7 +89,8 @@ public class GraphSerializationTestCase
throws Exception
{
MutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>> g =
- newUndirectedMutableGraph( buildWeightedGraphConnections() );
+ populate( new UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>() )
+ .withConnections( buildWeightedGraphConnections() );
checkSerialization( g );
}
@@ -93,7 +100,8 @@ public class GraphSerializationTestCase
throws Exception
{
MutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>> g =
- newDirectedMutableGraph( buildWeightedGraphConnections() );
+ populate( new UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>() )
+ .withConnections( buildWeightedGraphConnections() );
checkSerialization( g );
}
@@ -103,8 +111,7 @@ public class GraphSerializationTestCase
throws Exception
{
final MutableSpanningTree<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double> spanningTree =
- new MutableSpanningTree<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double>(
- new DoubleWeightBaseOperations(),
+ new MutableSpanningTree<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double>( new DoubleWeightBaseOperations(),
new BaseWeightedEdge<Double>() );
populate( spanningTree ).withConnections( buildWeightedGraphConnections() );
@@ -116,10 +123,11 @@ public class GraphSerializationTestCase
public void serializeSyncronyzedDirectedWeightdGraph()
throws Exception
{
- Graph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>> g =
- synchronize( (MutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>) newDirectedMutableGraph( buildWeightedGraphConnections() ) );
+ MutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>> g =
+ populate( new UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>>() )
+ .withConnections( buildWeightedGraphConnections() );
- checkSerialization( g );
+ checkSerialization( synchronize( g ) );
}
@Test
Added: commons/sandbox/graph/branches/modularization/model/src/test/java/org/apache/commons/graph/model/MultiThreadedTestRunner.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/model/src/test/java/org/apache/commons/graph/model/MultiThreadedTestRunner.java?rev=1486948&view=auto
==============================================================================
--- commons/sandbox/graph/branches/modularization/model/src/test/java/org/apache/commons/graph/model/MultiThreadedTestRunner.java (added)
+++ commons/sandbox/graph/branches/modularization/model/src/test/java/org/apache/commons/graph/model/MultiThreadedTestRunner.java Tue May 28 15:00:27 2013
@@ -0,0 +1,75 @@
+package org.apache.commons.graph.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Simple utility class.
+ * It is used for executing multi-thread test case.
+ */
+public class MultiThreadedTestRunner
+{
+
+ final private List<Thread> th;
+
+ long maxWait = 60L * 60L * 1000;
+
+ final private List<Throwable> exeptions;
+
+ public MultiThreadedTestRunner( TestRunner[] runnables )
+ {
+ th = new ArrayList<Thread>();
+ exeptions = new ArrayList<Throwable>();
+ for ( int i = 0; i < runnables.length; i++ )
+ {
+ runnables[i].setTestRunner( this );
+ th.add( new Thread( runnables[i] ) );
+ }
+ }
+
+ public void runRunnables() throws Throwable
+ {
+ for ( Thread t : th )
+ {
+ t.start();
+ }
+
+ for ( Thread t : th )
+ {
+ t.join( maxWait );
+ }
+
+ if ( this.exeptions.size() > 0 )
+ {
+ throw this.exeptions.get( 0 );
+ }
+ }
+
+ /**
+ * @param e
+ */
+ public void addException( Throwable e )
+ {
+ exeptions.add( e );
+ }
+
+}
Propchange: commons/sandbox/graph/branches/modularization/model/src/test/java/org/apache/commons/graph/model/MultiThreadedTestRunner.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/graph/branches/modularization/model/src/test/java/org/apache/commons/graph/model/MultiThreadedTestRunner.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/graph/branches/modularization/model/src/test/java/org/apache/commons/graph/model/MultiThreadedTestRunner.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/graph/branches/modularization/model/src/test/java/org/apache/commons/graph/model/TestRunner.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/model/src/test/java/org/apache/commons/graph/model/TestRunner.java?rev=1486948&view=auto
==============================================================================
--- commons/sandbox/graph/branches/modularization/model/src/test/java/org/apache/commons/graph/model/TestRunner.java (added)
+++ commons/sandbox/graph/branches/modularization/model/src/test/java/org/apache/commons/graph/model/TestRunner.java Tue May 28 15:00:27 2013
@@ -0,0 +1,51 @@
+package org.apache.commons.graph.model;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Abstract class. It's a generic multi-thread test case
+ *
+ */
+abstract public class TestRunner
+ implements Runnable
+{
+
+ private MultiThreadedTestRunner runner;
+
+ abstract public void runTest();
+
+ public void setTestRunner( MultiThreadedTestRunner runner )
+ {
+ this.runner = runner;
+ }
+
+ public void run()
+ {
+ try
+ {
+ runTest();
+ }
+ catch ( Throwable e )
+ {
+ runner.addException( e );
+ }
+ }
+
+}
Propchange: commons/sandbox/graph/branches/modularization/model/src/test/java/org/apache/commons/graph/model/TestRunner.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/graph/branches/modularization/model/src/test/java/org/apache/commons/graph/model/TestRunner.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/graph/branches/modularization/model/src/test/java/org/apache/commons/graph/model/TestRunner.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: commons/sandbox/graph/branches/modularization/pom.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/pom.xml?rev=1486948&r1=1486947&r2=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/pom.xml (original)
+++ commons/sandbox/graph/branches/modularization/pom.xml Tue May 28 15:00:27 2013
@@ -27,9 +27,9 @@
<groupId>org.apache.commons</groupId>
<artifactId>commons-graph</artifactId>
<version>0.1-SNAPSHOT</version>
- <packaging>jar</packaging>
+ <packaging>pom</packaging>
- <name>Apache Commons Graph</name>
+ <name>Apache Commons Graph - Parent</name>
<description>
The Apache Commons Graph package is a toolkit for managing graphs and graph based data structures.
</description>
@@ -116,6 +116,28 @@
</site>
</distributionManagement>
+ <modules>
+ <!-- foundation libs -->
+ <module>api</module>
+ <module>model</module>
+ <!-- aux collections -->
+ <module>collections/disjoint-set</module>
+ <module>collections/fibonacci-heap</module>
+ <!-- algorithms -->
+ <module>coloring</module>
+ <module>connectivity</module>
+ <module>elo</module>
+ <module>flow</module>
+ <module>scc</module>
+ <module>shortestpath</module>
+ <module>spanning</module>
+ <module>visit</module>
+ <!-- graph format export -->
+ <module>export</module>
+ <!-- aux tests -->
+ <module>benchmarks</module>
+ </modules>
+
<properties>
<maven.compile.source>1.5</maven.compile.source>
<maven.compile.target>1.5</maven.compile.target>
@@ -133,17 +155,6 @@
</dependencies>
<build>
- <resources>
- <resource>
- <directory>${basedir}</directory>
- <targetPath>META-INF</targetPath>
- <includes>
- <include>NOTICE.txt</include>
- <include>LICENSE.txt</include>
- </includes>
- </resource>
- </resources>
-
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself. -->
@@ -192,48 +203,13 @@
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
- <descriptor>src/main/assembly/bin.xml</descriptor>
- <descriptor>src/main/assembly/src.xml</descriptor>
+ <descriptor>${basedir}/src/main/assembly/bin.xml</descriptor>
+ <descriptor>${basedir}/src/main/assembly/src.xml</descriptor>
</descriptors>
<tarLongFileMode>gnu</tarLongFileMode>
+ <runOnlyAtExecutionRoot>true</runOnlyAtExecutionRoot>
</configuration>
</plugin>
-
- <plugin>
- <groupId>org.sonatype.plugins</groupId>
- <artifactId>jarjar-maven-plugin</artifactId>
- <version>1.5</version>
- <configuration>
- <input>{classes}</input>
- <output>${project.build.directory}/classes</output>
- <overwrite>true</overwrite>
- <skipManifest>true</skipManifest>
- <excludes>
- <exclude>*:*</exclude>
- </excludes>
- <rules>
- <rule>
- <pattern>org.apache.commons.graph.**.Default*</pattern>
- <result>org.apache.commons.graph.@1.$@2</result>
- </rule>
- <rule>
- <pattern>org.apache.commons.graph.utils.*</pattern>
- <result>org.apache.commons.graph.utils.$@1</result>
- </rule>
- <keep>
- <pattern>org.apache.commons.graph.**</pattern>
- </keep>
- </rules>
- </configuration>
- <executions>
- <execution>
- <phase>prepare-package</phase>
- <goals>
- <goal>jarjar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
</plugins>
</build>
@@ -295,74 +271,5 @@
</site>
</distributionManagement>
</profile>
-
- <profile>
- <id>benchmarks</id>
- <activation>
- <property>
- <name>skipBenchmarks</name>
- <value>!true</value>
- </property>
- </activation>
-
- <dependencies>
- <dependency>
- <groupId>com.carrotsearch</groupId>
- <artifactId>junit-benchmarks</artifactId>
- <classifier>jdk15</classifier>
- <version>0.3.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>1.6.1</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.h2database</groupId>
- <artifactId>h2</artifactId>
- <version>1.3.158</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <version>1.7</version>
- <executions>
- <execution>
- <id>add-test-source</id>
- <phase>generate-test-sources</phase>
- <goals>
- <goal>add-test-source</goal>
- </goals>
- <configuration>
- <sources>
- <source>${basedir}/src/benchmarks/java</source>
- </sources>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <systemPropertyVariables>
- <jub.consumers>CONSOLE,XML,H2</jub.consumers>
- <jub.db.file>${project.build.directory}/benchmarks/database</jub.db.file>
- <jub.xml.file>${project.build.directory}/benchmarks.xml</jub.xml.file>
- <jub.charts.dir>${project.build.directory}/site</jub.charts.dir>
- </systemPropertyVariables>
- <argLine>-Xmx512m -Xms512m</argLine>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
</profiles>
</project>
Propchange: commons/sandbox/graph/branches/modularization/scc/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue May 28 15:00:27 2013
@@ -0,0 +1,2 @@
+.settings
+target
Added: commons/sandbox/graph/branches/modularization/scc/pom.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/scc/pom.xml?rev=1486948&view=auto
==============================================================================
--- commons/sandbox/graph/branches/modularization/scc/pom.xml (added)
+++ commons/sandbox/graph/branches/modularization/scc/pom.xml Tue May 28 15:00:27 2013
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-graph</artifactId>
+ <version>0.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>commons-graph-scc</artifactId>
+
+ <name>Apache Commons Graph - SCC</name>
+ <description>Graph strongly connected component problem solver implementation.</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>${project.parent.groupId}</groupId>
+ <artifactId>commons-graph-api</artifactId>
+ <version>${project.parent.version}</version>
+ </dependency>
+
+ <!-- test dependencies -->
+ <dependency>
+ <groupId>${project.parent.groupId}</groupId>
+ <artifactId>commons-graph-model</artifactId>
+ <version>${project.parent.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <directory>${basedir}/../</directory>
+ <targetPath>META-INF</targetPath>
+ <includes>
+ <include>NOTICE.txt</include>
+ <include>LICENSE.txt</include>
+ </includes>
+ </resource>
+ </resources>
+ </build>
+
+</project>
Propchange: commons/sandbox/graph/branches/modularization/scc/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/graph/branches/modularization/scc/pom.xml
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: commons/sandbox/graph/branches/modularization/scc/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Modified: commons/sandbox/graph/branches/modularization/scc/src/main/java/org/apache/commons/graph/scc/KosarajuSharirAlgorithm.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/scc/src/main/java/org/apache/commons/graph/scc/KosarajuSharirAlgorithm.java?rev=1486948&r1=1486620&r2=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/scc/src/main/java/org/apache/commons/graph/scc/KosarajuSharirAlgorithm.java (original)
+++ commons/sandbox/graph/branches/modularization/scc/src/main/java/org/apache/commons/graph/scc/KosarajuSharirAlgorithm.java Tue May 28 15:00:27 2013
@@ -31,7 +31,7 @@ import java.util.List;
import java.util.Set;
import org.apache.commons.graph.DirectedGraph;
-import org.apache.commons.graph.model.RevertedGraph;
+import org.apache.commons.graph.RevertedGraph;
/**
* Implements the classical Kosaraju's algorithm to find the strongly connected components
Added: commons/sandbox/graph/branches/modularization/scc/src/main/java/org/apache/commons/graph/scc/SccSolver.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/scc/src/main/java/org/apache/commons/graph/scc/SccSolver.java?rev=1486948&view=auto
==============================================================================
--- commons/sandbox/graph/branches/modularization/scc/src/main/java/org/apache/commons/graph/scc/SccSolver.java (added)
+++ commons/sandbox/graph/branches/modularization/scc/src/main/java/org/apache/commons/graph/scc/SccSolver.java Tue May 28 15:00:27 2013
@@ -0,0 +1,49 @@
+package org.apache.commons.graph.scc;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import static org.apache.commons.graph.utils.Assertions.checkNotNull;
+
+import org.apache.commons.graph.DirectedGraph;
+
+public final class SccSolver
+{
+
+ /**
+ * Calculates the input graph Strongly Connected Component.
+ *
+ * @param <V> the Graph vertices type.
+ * @param <E> the Graph edges type.
+ * @param <G> the directed graph type
+ * @param graph the Graph which strongly connected component has to be verified.
+ * @return the SCC algoritm selector
+ */
+ public static <V, E, G extends DirectedGraph<V, E>> SccAlgorithmSelector<V, E> findStronglyConnectedComponent( G graph )
+ {
+ graph = checkNotNull( graph, "Strongly Connected Component cannot be calculated from a null graph" );
+ return new DefaultSccAlgorithmSelector<V, E>( graph );
+ }
+
+ private SccSolver()
+ {
+ // do nothing
+ }
+
+}
Propchange: commons/sandbox/graph/branches/modularization/scc/src/main/java/org/apache/commons/graph/scc/SccSolver.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/graph/branches/modularization/scc/src/main/java/org/apache/commons/graph/scc/SccSolver.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/graph/branches/modularization/scc/src/main/java/org/apache/commons/graph/scc/SccSolver.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: commons/sandbox/graph/branches/modularization/scc/src/test/java/org/apache/commons/graph/scc/CheriyanMehlhornGabowTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/scc/src/test/java/org/apache/commons/graph/scc/CheriyanMehlhornGabowTestCase.java?rev=1486948&r1=1486620&r2=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/scc/src/test/java/org/apache/commons/graph/scc/CheriyanMehlhornGabowTestCase.java (original)
+++ commons/sandbox/graph/branches/modularization/scc/src/test/java/org/apache/commons/graph/scc/CheriyanMehlhornGabowTestCase.java Tue May 28 15:00:27 2013
@@ -19,8 +19,8 @@ package org.apache.commons.graph.scc;
* under the License.
*/
-import static org.apache.commons.graph.CommonsGraph.findStronglyConnectedComponent;
-import static org.apache.commons.graph.CommonsGraph.newDirectedMutableGraph;
+import static org.apache.commons.graph.model.GraphUtils.newDirectedMutableGraph;
+import static org.apache.commons.graph.scc.SccSolver.findStronglyConnectedComponent;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -29,10 +29,10 @@ import java.util.HashSet;
import java.util.Set;
import org.apache.commons.graph.builder.AbstractGraphConnection;
-import org.apache.commons.graph.model.BaseLabeledEdge;
-import org.apache.commons.graph.model.BaseLabeledVertex;
-import org.apache.commons.graph.model.BaseLabeledWeightedEdge;
import org.apache.commons.graph.model.DirectedMutableGraph;
+import org.apache.commons.graph.model.labeled.BaseLabeledEdge;
+import org.apache.commons.graph.model.labeled.BaseLabeledVertex;
+import org.apache.commons.graph.model.labeled.BaseLabeledWeightedEdge;
import org.junit.Test;
/**
Modified: commons/sandbox/graph/branches/modularization/scc/src/test/java/org/apache/commons/graph/scc/KosarajuSharirTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/scc/src/test/java/org/apache/commons/graph/scc/KosarajuSharirTestCase.java?rev=1486948&r1=1486620&r2=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/scc/src/test/java/org/apache/commons/graph/scc/KosarajuSharirTestCase.java (original)
+++ commons/sandbox/graph/branches/modularization/scc/src/test/java/org/apache/commons/graph/scc/KosarajuSharirTestCase.java Tue May 28 15:00:27 2013
@@ -19,8 +19,8 @@ package org.apache.commons.graph.scc;
* under the License.
*/
-import static org.apache.commons.graph.CommonsGraph.findStronglyConnectedComponent;
-import static org.apache.commons.graph.CommonsGraph.newDirectedMutableGraph;
+import static org.apache.commons.graph.model.GraphUtils.newDirectedMutableGraph;
+import static org.apache.commons.graph.scc.SccSolver.findStronglyConnectedComponent;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -29,10 +29,10 @@ import java.util.HashSet;
import java.util.Set;
import org.apache.commons.graph.builder.AbstractGraphConnection;
-import org.apache.commons.graph.model.BaseLabeledEdge;
-import org.apache.commons.graph.model.BaseLabeledVertex;
-import org.apache.commons.graph.model.BaseLabeledWeightedEdge;
import org.apache.commons.graph.model.DirectedMutableGraph;
+import org.apache.commons.graph.model.labeled.BaseLabeledEdge;
+import org.apache.commons.graph.model.labeled.BaseLabeledVertex;
+import org.apache.commons.graph.model.labeled.BaseLabeledWeightedEdge;
import org.junit.Test;
/**
Modified: commons/sandbox/graph/branches/modularization/scc/src/test/java/org/apache/commons/graph/scc/TarjanTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/scc/src/test/java/org/apache/commons/graph/scc/TarjanTestCase.java?rev=1486948&r1=1486620&r2=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/scc/src/test/java/org/apache/commons/graph/scc/TarjanTestCase.java (original)
+++ commons/sandbox/graph/branches/modularization/scc/src/test/java/org/apache/commons/graph/scc/TarjanTestCase.java Tue May 28 15:00:27 2013
@@ -19,8 +19,8 @@ package org.apache.commons.graph.scc;
* under the License.
*/
-import static org.apache.commons.graph.CommonsGraph.findStronglyConnectedComponent;
-import static org.apache.commons.graph.CommonsGraph.newDirectedMutableGraph;
+import static org.apache.commons.graph.model.GraphUtils.newDirectedMutableGraph;
+import static org.apache.commons.graph.scc.SccSolver.findStronglyConnectedComponent;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -29,10 +29,10 @@ import java.util.HashSet;
import java.util.Set;
import org.apache.commons.graph.builder.AbstractGraphConnection;
-import org.apache.commons.graph.model.BaseLabeledEdge;
-import org.apache.commons.graph.model.BaseLabeledVertex;
-import org.apache.commons.graph.model.BaseLabeledWeightedEdge;
import org.apache.commons.graph.model.DirectedMutableGraph;
+import org.apache.commons.graph.model.labeled.BaseLabeledEdge;
+import org.apache.commons.graph.model.labeled.BaseLabeledVertex;
+import org.apache.commons.graph.model.labeled.BaseLabeledWeightedEdge;
import org.junit.Test;
/**
Propchange: commons/sandbox/graph/branches/modularization/shortestpath/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue May 28 15:00:27 2013
@@ -0,0 +1,2 @@
+.settings
+target
Added: commons/sandbox/graph/branches/modularization/shortestpath/pom.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/shortestpath/pom.xml?rev=1486948&view=auto
==============================================================================
--- commons/sandbox/graph/branches/modularization/shortestpath/pom.xml (added)
+++ commons/sandbox/graph/branches/modularization/shortestpath/pom.xml Tue May 28 15:00:27 2013
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-graph</artifactId>
+ <version>0.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>commons-graph-shortestpath</artifactId>
+
+ <name>Apache Commons Graph - Shortest Path</name>
+ <description>Graph shortest paths problem solver implementation.</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>${project.parent.groupId}</groupId>
+ <artifactId>commons-graph-api</artifactId>
+ <version>${project.parent.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.parent.groupId}</groupId>
+ <artifactId>commons-graph-fibonacciheap</artifactId>
+ <version>${project.parent.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.parent.groupId}</groupId>
+ <artifactId>commons-graph-model</artifactId>
+ <version>${project.parent.version}</version>
+ </dependency>
+ </dependencies>
+
+</project>
Propchange: commons/sandbox/graph/branches/modularization/shortestpath/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/graph/branches/modularization/shortestpath/pom.xml
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: commons/sandbox/graph/branches/modularization/shortestpath/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Modified: commons/sandbox/graph/branches/modularization/shortestpath/src/main/java/org/apache/commons/graph/shortestpath/AllVertexPairsShortestPath.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/shortestpath/src/main/java/org/apache/commons/graph/shortestpath/AllVertexPairsShortestPath.java?rev=1486948&r1=1486620&r2=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/shortestpath/src/main/java/org/apache/commons/graph/shortestpath/AllVertexPairsShortestPath.java (original)
+++ commons/sandbox/graph/branches/modularization/shortestpath/src/main/java/org/apache/commons/graph/shortestpath/AllVertexPairsShortestPath.java Tue May 28 15:00:27 2013
@@ -26,7 +26,8 @@ import java.util.Map;
import org.apache.commons.graph.VertexPair;
import org.apache.commons.graph.WeightedPath;
-import org.apache.commons.graph.weight.OrderedMonoid;
+import org.apache.commons.graph.math.monoid.OrderedMonoid;
+import org.apache.commons.graph.model.PathNotFoundException;
/**
* Represents all shortest paths between all vertex pairs calculated by {@link FloydWarshall} algorithm.
Modified: commons/sandbox/graph/branches/modularization/shortestpath/src/main/java/org/apache/commons/graph/shortestpath/DefaultHeuristicBuilder.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/shortestpath/src/main/java/org/apache/commons/graph/shortestpath/DefaultHeuristicBuilder.java?rev=1486948&r1=1486620&r2=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/shortestpath/src/main/java/org/apache/commons/graph/shortestpath/DefaultHeuristicBuilder.java (original)
+++ commons/sandbox/graph/branches/modularization/shortestpath/src/main/java/org/apache/commons/graph/shortestpath/DefaultHeuristicBuilder.java Tue May 28 15:00:27 2013
@@ -30,7 +30,9 @@ import org.apache.commons.graph.Graph;
import org.apache.commons.graph.Mapper;
import org.apache.commons.graph.WeightedPath;
import org.apache.commons.graph.collections.FibonacciHeap;
-import org.apache.commons.graph.weight.OrderedMonoid;
+import org.apache.commons.graph.math.monoid.OrderedMonoid;
+import org.apache.commons.graph.model.PathNotFoundException;
+import org.apache.commons.graph.model.PredecessorsList;
final class DefaultHeuristicBuilder<V, WE, W>
implements HeuristicBuilder<V, WE, W>
Modified: commons/sandbox/graph/branches/modularization/shortestpath/src/main/java/org/apache/commons/graph/shortestpath/DefaultPathSourceSelector.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/shortestpath/src/main/java/org/apache/commons/graph/shortestpath/DefaultPathSourceSelector.java?rev=1486948&r1=1486620&r2=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/shortestpath/src/main/java/org/apache/commons/graph/shortestpath/DefaultPathSourceSelector.java (original)
+++ commons/sandbox/graph/branches/modularization/shortestpath/src/main/java/org/apache/commons/graph/shortestpath/DefaultPathSourceSelector.java Tue May 28 15:00:27 2013
@@ -25,11 +25,12 @@ import java.util.HashMap;
import java.util.Map;
import org.apache.commons.graph.Graph;
+import org.apache.commons.graph.Mapper;
import org.apache.commons.graph.UndirectedGraph;
import org.apache.commons.graph.VertexPair;
-import org.apache.commons.graph.Mapper;
import org.apache.commons.graph.WeightedPath;
-import org.apache.commons.graph.weight.OrderedMonoid;
+import org.apache.commons.graph.math.monoid.OrderedMonoid;
+import org.apache.commons.graph.model.PredecessorsList;
final class DefaultPathSourceSelector<V, WE, W>
implements PathSourceSelector<V, WE, W>
Modified: commons/sandbox/graph/branches/modularization/shortestpath/src/main/java/org/apache/commons/graph/shortestpath/DefaultShortestPathAlgorithmSelector.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/shortestpath/src/main/java/org/apache/commons/graph/shortestpath/DefaultShortestPathAlgorithmSelector.java?rev=1486948&r1=1486620&r2=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/shortestpath/src/main/java/org/apache/commons/graph/shortestpath/DefaultShortestPathAlgorithmSelector.java (original)
+++ commons/sandbox/graph/branches/modularization/shortestpath/src/main/java/org/apache/commons/graph/shortestpath/DefaultShortestPathAlgorithmSelector.java Tue May 28 15:00:27 2013
@@ -24,13 +24,15 @@ import static org.apache.commons.graph.u
import java.util.HashSet;
import java.util.Queue;
import java.util.Set;
-import org.apache.commons.graph.DirectedGraph;
+import org.apache.commons.graph.DirectedGraph;
import org.apache.commons.graph.Graph;
import org.apache.commons.graph.Mapper;
import org.apache.commons.graph.WeightedPath;
import org.apache.commons.graph.collections.FibonacciHeap;
-import org.apache.commons.graph.weight.OrderedMonoid;
+import org.apache.commons.graph.math.monoid.OrderedMonoid;
+import org.apache.commons.graph.model.PathNotFoundException;
+import org.apache.commons.graph.model.PredecessorsList;
final class DefaultShortestPathAlgorithmSelector<V, WE, W>
implements ShortestPathAlgorithmSelector<V, WE, W>
Modified: commons/sandbox/graph/branches/modularization/shortestpath/src/main/java/org/apache/commons/graph/shortestpath/DefaultTargetSourceSelector.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/shortestpath/src/main/java/org/apache/commons/graph/shortestpath/DefaultTargetSourceSelector.java?rev=1486948&r1=1486620&r2=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/shortestpath/src/main/java/org/apache/commons/graph/shortestpath/DefaultTargetSourceSelector.java (original)
+++ commons/sandbox/graph/branches/modularization/shortestpath/src/main/java/org/apache/commons/graph/shortestpath/DefaultTargetSourceSelector.java Tue May 28 15:00:27 2013
@@ -22,10 +22,12 @@ package org.apache.commons.graph.shortes
import static org.apache.commons.graph.utils.Assertions.checkNotNull;
import org.apache.commons.graph.Graph;
-import org.apache.commons.graph.VertexPair;
import org.apache.commons.graph.Mapper;
+import org.apache.commons.graph.VertexPair;
import org.apache.commons.graph.WeightedPath;
-import org.apache.commons.graph.weight.OrderedMonoid;
+import org.apache.commons.graph.math.monoid.OrderedMonoid;
+import org.apache.commons.graph.model.PathNotFoundException;
+import org.apache.commons.graph.model.PredecessorsList;
final class DefaultTargetSourceSelector<V, WE, W>
implements TargetSourceSelector<V, WE, W>
Modified: commons/sandbox/graph/branches/modularization/shortestpath/src/main/java/org/apache/commons/graph/shortestpath/PathSourceSelector.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/shortestpath/src/main/java/org/apache/commons/graph/shortestpath/PathSourceSelector.java?rev=1486948&r1=1486620&r2=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/shortestpath/src/main/java/org/apache/commons/graph/shortestpath/PathSourceSelector.java (original)
+++ commons/sandbox/graph/branches/modularization/shortestpath/src/main/java/org/apache/commons/graph/shortestpath/PathSourceSelector.java Tue May 28 15:00:27 2013
@@ -19,7 +19,7 @@ package org.apache.commons.graph.shortes
* under the License.
*/
-import org.apache.commons.graph.weight.OrderedMonoid;
+import org.apache.commons.graph.math.monoid.OrderedMonoid;
/**
*
Modified: commons/sandbox/graph/branches/modularization/shortestpath/src/main/java/org/apache/commons/graph/shortestpath/ShortestDistances.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/shortestpath/src/main/java/org/apache/commons/graph/shortestpath/ShortestDistances.java?rev=1486948&r1=1486620&r2=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/shortestpath/src/main/java/org/apache/commons/graph/shortestpath/ShortestDistances.java (original)
+++ commons/sandbox/graph/branches/modularization/shortestpath/src/main/java/org/apache/commons/graph/shortestpath/ShortestDistances.java Tue May 28 15:00:27 2013
@@ -23,7 +23,7 @@ import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
-import org.apache.commons.graph.weight.OrderedMonoid;
+import org.apache.commons.graph.math.monoid.OrderedMonoid;
/**
* Stores and compares Graph Vertices weights.
Modified: commons/sandbox/graph/branches/modularization/shortestpath/src/main/java/org/apache/commons/graph/shortestpath/ShortestPathAlgorithmSelector.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/shortestpath/src/main/java/org/apache/commons/graph/shortestpath/ShortestPathAlgorithmSelector.java?rev=1486948&r1=1486620&r2=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/shortestpath/src/main/java/org/apache/commons/graph/shortestpath/ShortestPathAlgorithmSelector.java (original)
+++ commons/sandbox/graph/branches/modularization/shortestpath/src/main/java/org/apache/commons/graph/shortestpath/ShortestPathAlgorithmSelector.java Tue May 28 15:00:27 2013
@@ -20,7 +20,8 @@ package org.apache.commons.graph.shortes
*/
import org.apache.commons.graph.WeightedPath;
-import org.apache.commons.graph.weight.OrderedMonoid;
+import org.apache.commons.graph.math.monoid.OrderedMonoid;
+import org.apache.commons.graph.model.PathNotFoundException;
/**
*
Added: commons/sandbox/graph/branches/modularization/shortestpath/src/main/java/org/apache/commons/graph/shortestpath/ShortestPathSolver.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/shortestpath/src/main/java/org/apache/commons/graph/shortestpath/ShortestPathSolver.java?rev=1486948&view=auto
==============================================================================
--- commons/sandbox/graph/branches/modularization/shortestpath/src/main/java/org/apache/commons/graph/shortestpath/ShortestPathSolver.java (added)
+++ commons/sandbox/graph/branches/modularization/shortestpath/src/main/java/org/apache/commons/graph/shortestpath/ShortestPathSolver.java Tue May 28 15:00:27 2013
@@ -0,0 +1,49 @@
+package org.apache.commons.graph.shortestpath;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import static org.apache.commons.graph.utils.Assertions.checkNotNull;
+
+import org.apache.commons.graph.Graph;
+
+public final class ShortestPathSolver
+{
+
+ /**
+ * Find the sortest on the input {@link Graph}
+ *
+ * @param <V> the Graph vertices type
+ * @param <WE> the Graph edges type
+ * @param <G> the Graph type
+ * @param graph the input edge-weighted graph
+ * @return the caluculated the sortest
+ */
+ public static <V, WE, G extends Graph<V, WE>> PathWeightedEdgesBuilder<V, WE> findShortestPath( G graph )
+ {
+ graph = checkNotNull( graph, "Shortest path can not be calculated on null graph" );
+ return new DefaultWeightedEdgesSelector<V, WE>( graph );
+ }
+
+ private ShortestPathSolver()
+ {
+ // do nothing
+ }
+
+}
Propchange: commons/sandbox/graph/branches/modularization/shortestpath/src/main/java/org/apache/commons/graph/shortestpath/ShortestPathSolver.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/graph/branches/modularization/shortestpath/src/main/java/org/apache/commons/graph/shortestpath/ShortestPathSolver.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/graph/branches/modularization/shortestpath/src/main/java/org/apache/commons/graph/shortestpath/ShortestPathSolver.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: commons/sandbox/graph/branches/modularization/shortestpath/src/main/java/org/apache/commons/graph/shortestpath/TargetSourceSelector.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/shortestpath/src/main/java/org/apache/commons/graph/shortestpath/TargetSourceSelector.java?rev=1486948&r1=1486620&r2=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/shortestpath/src/main/java/org/apache/commons/graph/shortestpath/TargetSourceSelector.java (original)
+++ commons/sandbox/graph/branches/modularization/shortestpath/src/main/java/org/apache/commons/graph/shortestpath/TargetSourceSelector.java Tue May 28 15:00:27 2013
@@ -19,7 +19,7 @@ package org.apache.commons.graph.shortes
* under the License.
*/
-import org.apache.commons.graph.weight.OrderedMonoid;
+import org.apache.commons.graph.math.monoid.OrderedMonoid;
/**
*
Modified: commons/sandbox/graph/branches/modularization/shortestpath/src/test/java/org/apache/commons/graph/shortestpath/AStarTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/shortestpath/src/test/java/org/apache/commons/graph/shortestpath/AStarTestCase.java?rev=1486948&r1=1486620&r2=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/shortestpath/src/test/java/org/apache/commons/graph/shortestpath/AStarTestCase.java (original)
+++ commons/sandbox/graph/branches/modularization/shortestpath/src/test/java/org/apache/commons/graph/shortestpath/AStarTestCase.java Tue May 28 15:00:27 2013
@@ -19,8 +19,8 @@ package org.apache.commons.graph.shortes
* under the License.
*/
+import static org.apache.commons.graph.shortestpath.ShortestPathSolver.findShortestPath;
import static org.junit.Assert.assertEquals;
-import static org.apache.commons.graph.CommonsGraph.findShortestPath;
import static org.junit.Assert.fail;
import java.util.HashMap;
@@ -28,12 +28,13 @@ import java.util.Map;
import org.apache.commons.graph.Graph;
import org.apache.commons.graph.Path;
-import org.apache.commons.graph.model.BaseLabeledVertex;
-import org.apache.commons.graph.model.BaseLabeledWeightedEdge;
-import org.apache.commons.graph.model.BaseWeightedEdge;
+import org.apache.commons.graph.math.monoid.primitive.DoubleWeightBaseOperations;
import org.apache.commons.graph.model.InMemoryWeightedPath;
+import org.apache.commons.graph.model.PathNotFoundException;
import org.apache.commons.graph.model.UndirectedMutableGraph;
-import org.apache.commons.graph.weight.primitive.DoubleWeightBaseOperations;
+import org.apache.commons.graph.model.labeled.BaseLabeledVertex;
+import org.apache.commons.graph.model.labeled.BaseLabeledWeightedEdge;
+import org.apache.commons.graph.model.labeled.BaseWeightedEdge;
import org.junit.Test;
public final class AStarTestCase
Modified: commons/sandbox/graph/branches/modularization/shortestpath/src/test/java/org/apache/commons/graph/shortestpath/BellmannFordTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/shortestpath/src/test/java/org/apache/commons/graph/shortestpath/BellmannFordTestCase.java?rev=1486948&r1=1486620&r2=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/shortestpath/src/test/java/org/apache/commons/graph/shortestpath/BellmannFordTestCase.java (original)
+++ commons/sandbox/graph/branches/modularization/shortestpath/src/test/java/org/apache/commons/graph/shortestpath/BellmannFordTestCase.java Tue May 28 15:00:27 2013
@@ -19,19 +19,20 @@ package org.apache.commons.graph.shortes
* under the License.
*/
+import static org.apache.commons.graph.shortestpath.ShortestPathSolver.findShortestPath;
import static org.junit.Assert.assertEquals;
-import static org.apache.commons.graph.CommonsGraph.findShortestPath;
import static org.junit.Assert.fail;
import org.apache.commons.graph.Graph;
import org.apache.commons.graph.WeightedPath;
-import org.apache.commons.graph.model.BaseLabeledVertex;
-import org.apache.commons.graph.model.BaseLabeledWeightedEdge;
-import org.apache.commons.graph.model.BaseWeightedEdge;
+import org.apache.commons.graph.math.monoid.primitive.DoubleWeightBaseOperations;
import org.apache.commons.graph.model.DirectedMutableGraph;
import org.apache.commons.graph.model.InMemoryWeightedPath;
+import org.apache.commons.graph.model.PathNotFoundException;
import org.apache.commons.graph.model.UndirectedMutableGraph;
-import org.apache.commons.graph.weight.primitive.DoubleWeightBaseOperations;
+import org.apache.commons.graph.model.labeled.BaseLabeledVertex;
+import org.apache.commons.graph.model.labeled.BaseLabeledWeightedEdge;
+import org.apache.commons.graph.model.labeled.BaseWeightedEdge;
import org.junit.Test;
public final class BellmannFordTestCase
Modified: commons/sandbox/graph/branches/modularization/shortestpath/src/test/java/org/apache/commons/graph/shortestpath/BidirDijkstraTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/shortestpath/src/test/java/org/apache/commons/graph/shortestpath/BidirDijkstraTestCase.java?rev=1486948&r1=1486620&r2=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/shortestpath/src/test/java/org/apache/commons/graph/shortestpath/BidirDijkstraTestCase.java (original)
+++ commons/sandbox/graph/branches/modularization/shortestpath/src/test/java/org/apache/commons/graph/shortestpath/BidirDijkstraTestCase.java Tue May 28 15:00:27 2013
@@ -19,40 +19,42 @@ package org.apache.commons.graph.shortes
* under the License.
*/
-import static org.junit.Assert.assertEquals;
-
-import org.apache.commons.graph.Graph;
-import org.apache.commons.graph.Path;
-import org.apache.commons.graph.model.InMemoryWeightedPath;
-
import static java.lang.String.format;
import static java.lang.String.valueOf;
-import static org.apache.commons.graph.CommonsGraph.findShortestPath;
-import static org.apache.commons.graph.CommonsGraph.newDirectedMutableGraph;
+import static org.apache.commons.graph.model.GraphUtils.newDirectedMutableGraph;
+import static org.apache.commons.graph.shortestpath.ShortestPathSolver.findShortestPath;
+import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
+import org.apache.commons.graph.Graph;
import org.apache.commons.graph.GraphException;
+import org.apache.commons.graph.Path;
+import org.apache.commons.graph.WeightedPath;
import org.apache.commons.graph.builder.AbstractGraphConnection;
-import org.apache.commons.graph.model.BaseLabeledVertex;
-import org.apache.commons.graph.model.BaseLabeledWeightedEdge;
+import org.apache.commons.graph.math.monoid.OrderedMonoid;
+import org.apache.commons.graph.math.monoid.primitive.DoubleWeightBaseOperations;
+import org.apache.commons.graph.model.DirectedMutableGraph;
+import org.apache.commons.graph.model.InMemoryWeightedPath;
+import org.apache.commons.graph.model.PathNotFoundException;
import org.apache.commons.graph.model.UndirectedMutableGraph;
-import org.apache.commons.graph.weight.primitive.DoubleWeightBaseOperations;
+import org.apache.commons.graph.model.labeled.BaseLabeledVertex;
+import org.apache.commons.graph.model.labeled.BaseLabeledWeightedEdge;
+import org.apache.commons.graph.model.labeled.BaseWeightedEdge;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.apache.commons.graph.WeightedPath;
-import org.apache.commons.graph.model.BaseWeightedEdge;
-import org.apache.commons.graph.model.DirectedMutableGraph;
-import org.apache.commons.graph.weight.OrderedMonoid;
-
public final class BidirDijkstraTestCase
{
+
private static final int TIMES = 10;
+
private static final int NODES = 5000;
+
private static final int EDGES = 100000;
+
private static final double EPSILON = 1.0e-6;
private static DirectedMutableGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>> graph;
Modified: commons/sandbox/graph/branches/modularization/shortestpath/src/test/java/org/apache/commons/graph/shortestpath/DijkstraTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/shortestpath/src/test/java/org/apache/commons/graph/shortestpath/DijkstraTestCase.java?rev=1486948&r1=1486620&r2=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/shortestpath/src/test/java/org/apache/commons/graph/shortestpath/DijkstraTestCase.java (original)
+++ commons/sandbox/graph/branches/modularization/shortestpath/src/test/java/org/apache/commons/graph/shortestpath/DijkstraTestCase.java Tue May 28 15:00:27 2013
@@ -19,18 +19,19 @@ package org.apache.commons.graph.shortes
* under the License.
*/
+import static org.apache.commons.graph.shortestpath.ShortestPathSolver.findShortestPath;
import static org.junit.Assert.assertEquals;
-import static org.apache.commons.graph.CommonsGraph.findShortestPath;
import org.apache.commons.graph.Graph;
import org.apache.commons.graph.Path;
-import org.apache.commons.graph.model.BaseLabeledVertex;
-import org.apache.commons.graph.model.BaseLabeledWeightedEdge;
-import org.apache.commons.graph.model.BaseWeightedEdge;
+import org.apache.commons.graph.math.monoid.primitive.DoubleWeightBaseOperations;
import org.apache.commons.graph.model.DirectedMutableGraph;
import org.apache.commons.graph.model.InMemoryWeightedPath;
+import org.apache.commons.graph.model.PathNotFoundException;
import org.apache.commons.graph.model.UndirectedMutableGraph;
-import org.apache.commons.graph.weight.primitive.DoubleWeightBaseOperations;
+import org.apache.commons.graph.model.labeled.BaseLabeledVertex;
+import org.apache.commons.graph.model.labeled.BaseLabeledWeightedEdge;
+import org.apache.commons.graph.model.labeled.BaseWeightedEdge;
import org.junit.Test;
public final class DijkstraTestCase
Modified: commons/sandbox/graph/branches/modularization/shortestpath/src/test/java/org/apache/commons/graph/shortestpath/FloydWarshallTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/shortestpath/src/test/java/org/apache/commons/graph/shortestpath/FloydWarshallTestCase.java?rev=1486948&r1=1486620&r2=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/shortestpath/src/test/java/org/apache/commons/graph/shortestpath/FloydWarshallTestCase.java (original)
+++ commons/sandbox/graph/branches/modularization/shortestpath/src/test/java/org/apache/commons/graph/shortestpath/FloydWarshallTestCase.java Tue May 28 15:00:27 2013
@@ -20,21 +20,22 @@ package org.apache.commons.graph.shortes
*/
import static junit.framework.Assert.assertEquals;
+import static org.apache.commons.graph.shortestpath.ShortestPathSolver.findShortestPath;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.fail;
-import static org.apache.commons.graph.CommonsGraph.findShortestPath;
import org.apache.commons.graph.Graph;
import org.apache.commons.graph.MutableGraph;
import org.apache.commons.graph.UndirectedGraph;
import org.apache.commons.graph.WeightedPath;
-import org.apache.commons.graph.model.BaseLabeledVertex;
-import org.apache.commons.graph.model.BaseLabeledWeightedEdge;
-import org.apache.commons.graph.model.BaseWeightedEdge;
+import org.apache.commons.graph.math.monoid.primitive.DoubleWeightBaseOperations;
import org.apache.commons.graph.model.DirectedMutableGraph;
import org.apache.commons.graph.model.InMemoryWeightedPath;
+import org.apache.commons.graph.model.PathNotFoundException;
import org.apache.commons.graph.model.UndirectedMutableGraph;
-import org.apache.commons.graph.weight.primitive.DoubleWeightBaseOperations;
+import org.apache.commons.graph.model.labeled.BaseLabeledVertex;
+import org.apache.commons.graph.model.labeled.BaseLabeledWeightedEdge;
+import org.apache.commons.graph.model.labeled.BaseWeightedEdge;
import org.junit.Test;
/**
Propchange: commons/sandbox/graph/branches/modularization/spanning/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue May 28 15:00:27 2013
@@ -0,0 +1,2 @@
+.settings
+target
Added: commons/sandbox/graph/branches/modularization/spanning/pom.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/spanning/pom.xml?rev=1486948&view=auto
==============================================================================
--- commons/sandbox/graph/branches/modularization/spanning/pom.xml (added)
+++ commons/sandbox/graph/branches/modularization/spanning/pom.xml Tue May 28 15:00:27 2013
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-graph</artifactId>
+ <version>0.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>commons-graph-spanning</artifactId>
+
+ <name>Apache Commons Graph - Spanning</name>
+ <description>Graph spanning tree problem solver implementation.</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>${project.parent.groupId}</groupId>
+ <artifactId>commons-graph-api</artifactId>
+ <version>${project.parent.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.parent.groupId}</groupId>
+ <artifactId>commons-graph-disjointset</artifactId>
+ <version>${project.parent.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.parent.groupId}</groupId>
+ <artifactId>commons-graph-fibonacciheap</artifactId>
+ <version>${project.parent.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.parent.groupId}</groupId>
+ <artifactId>commons-graph-shortestpath</artifactId>
+ <version>${project.parent.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.parent.groupId}</groupId>
+ <artifactId>commons-graph-model</artifactId>
+ <version>${project.parent.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <directory>${basedir}/../</directory>
+ <targetPath>META-INF</targetPath>
+ <includes>
+ <include>NOTICE.txt</include>
+ <include>LICENSE.txt</include>
+ </includes>
+ </resource>
+ </resources>
+ </build>
+
+</project>
Propchange: commons/sandbox/graph/branches/modularization/spanning/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/graph/branches/modularization/spanning/pom.xml
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: commons/sandbox/graph/branches/modularization/spanning/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Modified: commons/sandbox/graph/branches/modularization/spanning/src/main/java/org/apache/commons/graph/spanning/DefaultSpanningTreeAlgorithmSelector.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/spanning/src/main/java/org/apache/commons/graph/spanning/DefaultSpanningTreeAlgorithmSelector.java?rev=1486948&r1=1486620&r2=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/spanning/src/main/java/org/apache/commons/graph/spanning/DefaultSpanningTreeAlgorithmSelector.java (original)
+++ commons/sandbox/graph/branches/modularization/spanning/src/main/java/org/apache/commons/graph/spanning/DefaultSpanningTreeAlgorithmSelector.java Tue May 28 15:00:27 2013
@@ -36,8 +36,8 @@ import org.apache.commons.graph.Spanning
import org.apache.commons.graph.VertexPair;
import org.apache.commons.graph.collections.DisjointSet;
import org.apache.commons.graph.collections.FibonacciHeap;
+import org.apache.commons.graph.math.monoid.OrderedMonoid;
import org.apache.commons.graph.model.MutableSpanningTree;
-import org.apache.commons.graph.weight.OrderedMonoid;
/**
* {@link SpanningTreeAlgorithmSelector} implementation.
Modified: commons/sandbox/graph/branches/modularization/spanning/src/main/java/org/apache/commons/graph/spanning/DefaultSpanningTreeSourceSelector.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/spanning/src/main/java/org/apache/commons/graph/spanning/DefaultSpanningTreeSourceSelector.java?rev=1486948&r1=1486620&r2=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/spanning/src/main/java/org/apache/commons/graph/spanning/DefaultSpanningTreeSourceSelector.java (original)
+++ commons/sandbox/graph/branches/modularization/spanning/src/main/java/org/apache/commons/graph/spanning/DefaultSpanningTreeSourceSelector.java Tue May 28 15:00:27 2013
@@ -20,7 +20,7 @@ package org.apache.commons.graph.spannin
*/
import static java.util.Collections.reverseOrder;
-import static org.apache.commons.graph.CommonsGraph.findShortestPath;
+import static org.apache.commons.graph.shortestpath.ShortestPathSolver.findShortestPath;
import static org.apache.commons.graph.utils.Assertions.checkNotNull;
import static org.apache.commons.graph.utils.Assertions.checkState;
@@ -33,9 +33,9 @@ import org.apache.commons.graph.Graph;
import org.apache.commons.graph.Mapper;
import org.apache.commons.graph.SpanningTree;
import org.apache.commons.graph.VertexPair;
+import org.apache.commons.graph.math.monoid.OrderedMonoid;
import org.apache.commons.graph.model.MutableSpanningTree;
-import org.apache.commons.graph.shortestpath.PathNotFoundException;
-import org.apache.commons.graph.weight.OrderedMonoid;
+import org.apache.commons.graph.model.PathNotFoundException;
/**
* {@link SpanningTreeSourceSelector} implementation.
@@ -82,7 +82,6 @@ final class DefaultSpanningTreeSourceSel
*/
public <WO extends OrderedMonoid<W>> SpanningTree<V, WE, W> applyingReverseDeleteAlgorithm( WO weightOperations )
{
-
checkNotNull( weightOperations, "The Reverse-Delete algorithm cannot be calulated with null weight operations" );
final Queue<WE> sortedEdge = new PriorityQueue<WE>( 11, reverseOrder( new WeightedEdgesComparator<W, WE>( weightOperations, weightedEdges ) ) );
Modified: commons/sandbox/graph/branches/modularization/spanning/src/main/java/org/apache/commons/graph/spanning/ShortestEdges.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/spanning/src/main/java/org/apache/commons/graph/spanning/ShortestEdges.java?rev=1486948&r1=1486620&r2=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/spanning/src/main/java/org/apache/commons/graph/spanning/ShortestEdges.java (original)
+++ commons/sandbox/graph/branches/modularization/spanning/src/main/java/org/apache/commons/graph/spanning/ShortestEdges.java Tue May 28 15:00:27 2013
@@ -28,8 +28,8 @@ import org.apache.commons.graph.GraphExc
import org.apache.commons.graph.Mapper;
import org.apache.commons.graph.SpanningTree;
import org.apache.commons.graph.VertexPair;
+import org.apache.commons.graph.math.monoid.OrderedMonoid;
import org.apache.commons.graph.model.MutableSpanningTree;
-import org.apache.commons.graph.weight.OrderedMonoid;
/**
* The predecessor list is a list of vertex of a {@link org.apache.commons.graph.Graph}.
Modified: commons/sandbox/graph/branches/modularization/spanning/src/main/java/org/apache/commons/graph/spanning/SpanningTreeAlgorithmSelector.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/spanning/src/main/java/org/apache/commons/graph/spanning/SpanningTreeAlgorithmSelector.java?rev=1486948&r1=1486620&r2=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/spanning/src/main/java/org/apache/commons/graph/spanning/SpanningTreeAlgorithmSelector.java (original)
+++ commons/sandbox/graph/branches/modularization/spanning/src/main/java/org/apache/commons/graph/spanning/SpanningTreeAlgorithmSelector.java Tue May 28 15:00:27 2013
@@ -20,7 +20,7 @@ package org.apache.commons.graph.spannin
*/
import org.apache.commons.graph.SpanningTree;
-import org.apache.commons.graph.weight.OrderedMonoid;
+import org.apache.commons.graph.math.monoid.OrderedMonoid;
/**
* Spanning Tree algoritms selector.
Added: commons/sandbox/graph/branches/modularization/spanning/src/main/java/org/apache/commons/graph/spanning/SpanningTreeSolver.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/spanning/src/main/java/org/apache/commons/graph/spanning/SpanningTreeSolver.java?rev=1486948&view=auto
==============================================================================
--- commons/sandbox/graph/branches/modularization/spanning/src/main/java/org/apache/commons/graph/spanning/SpanningTreeSolver.java (added)
+++ commons/sandbox/graph/branches/modularization/spanning/src/main/java/org/apache/commons/graph/spanning/SpanningTreeSolver.java Tue May 28 15:00:27 2013
@@ -0,0 +1,49 @@
+package org.apache.commons.graph.spanning;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import static org.apache.commons.graph.utils.Assertions.checkNotNull;
+
+import org.apache.commons.graph.Graph;
+
+public final class SpanningTreeSolver
+{
+
+ /**
+ * Find the minimum spanning tree on the input {@link Graph}
+ *
+ * @param <V> the Graph vertices type
+ * @param <WE> the Graph edges type
+ * @param <G> the Graph type
+ * @param graph the input edge-weighted graph
+ * @return the caluculated minimun spanning tree
+ */
+ public static <V, WE, G extends Graph<V, WE>> SpanningWeightedEdgeMapperBuilder<V, WE> minimumSpanningTree( G graph )
+ {
+ graph = checkNotNull( graph, "Minimum spanning tree can not be calculated on null graph" );
+ return new DefaultSpanningWeightedEdgeMapperBuilder<V, WE>( graph );
+ }
+
+ private SpanningTreeSolver()
+ {
+ // do nothing
+ }
+
+}
Propchange: commons/sandbox/graph/branches/modularization/spanning/src/main/java/org/apache/commons/graph/spanning/SpanningTreeSolver.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/graph/branches/modularization/spanning/src/main/java/org/apache/commons/graph/spanning/SpanningTreeSolver.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/graph/branches/modularization/spanning/src/main/java/org/apache/commons/graph/spanning/SpanningTreeSolver.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: commons/sandbox/graph/branches/modularization/spanning/src/main/java/org/apache/commons/graph/spanning/SpanningTreeSourceSelector.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/spanning/src/main/java/org/apache/commons/graph/spanning/SpanningTreeSourceSelector.java?rev=1486948&r1=1486620&r2=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/spanning/src/main/java/org/apache/commons/graph/spanning/SpanningTreeSourceSelector.java (original)
+++ commons/sandbox/graph/branches/modularization/spanning/src/main/java/org/apache/commons/graph/spanning/SpanningTreeSourceSelector.java Tue May 28 15:00:27 2013
@@ -20,7 +20,7 @@ package org.apache.commons.graph.spannin
*/
import org.apache.commons.graph.SpanningTree;
-import org.apache.commons.graph.weight.OrderedMonoid;
+import org.apache.commons.graph.math.monoid.OrderedMonoid;
/**
* Spanning Tree source selector.
Modified: commons/sandbox/graph/branches/modularization/spanning/src/test/java/org/apache/commons/graph/spanning/BoruvkaTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/spanning/src/test/java/org/apache/commons/graph/spanning/BoruvkaTestCase.java?rev=1486948&r1=1486620&r2=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/spanning/src/test/java/org/apache/commons/graph/spanning/BoruvkaTestCase.java (original)
+++ commons/sandbox/graph/branches/modularization/spanning/src/test/java/org/apache/commons/graph/spanning/BoruvkaTestCase.java Tue May 28 15:00:27 2013
@@ -19,18 +19,18 @@ package org.apache.commons.graph.spannin
* under the License.
*/
+import static org.apache.commons.graph.spanning.SpanningTreeSolver.minimumSpanningTree;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
-import static org.apache.commons.graph.CommonsGraph.minimumSpanningTree;
import org.apache.commons.graph.Graph;
import org.apache.commons.graph.SpanningTree;
-import org.apache.commons.graph.model.BaseLabeledVertex;
-import org.apache.commons.graph.model.BaseLabeledWeightedEdge;
-import org.apache.commons.graph.model.BaseWeightedEdge;
+import org.apache.commons.graph.math.monoid.primitive.DoubleWeightBaseOperations;
import org.apache.commons.graph.model.MutableSpanningTree;
import org.apache.commons.graph.model.UndirectedMutableGraph;
-import org.apache.commons.graph.weight.primitive.DoubleWeightBaseOperations;
+import org.apache.commons.graph.model.labeled.BaseLabeledVertex;
+import org.apache.commons.graph.model.labeled.BaseLabeledWeightedEdge;
+import org.apache.commons.graph.model.labeled.BaseWeightedEdge;
import org.junit.Test;
public final class BoruvkaTestCase
Modified: commons/sandbox/graph/branches/modularization/spanning/src/test/java/org/apache/commons/graph/spanning/KruskalTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/spanning/src/test/java/org/apache/commons/graph/spanning/KruskalTestCase.java?rev=1486948&r1=1486620&r2=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/spanning/src/test/java/org/apache/commons/graph/spanning/KruskalTestCase.java (original)
+++ commons/sandbox/graph/branches/modularization/spanning/src/test/java/org/apache/commons/graph/spanning/KruskalTestCase.java Tue May 28 15:00:27 2013
@@ -19,18 +19,18 @@ package org.apache.commons.graph.spannin
* under the License.
*/
+import static org.apache.commons.graph.spanning.SpanningTreeSolver.minimumSpanningTree;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
-import static org.apache.commons.graph.CommonsGraph.minimumSpanningTree;
import org.apache.commons.graph.Graph;
import org.apache.commons.graph.SpanningTree;
-import org.apache.commons.graph.model.BaseLabeledVertex;
-import org.apache.commons.graph.model.BaseLabeledWeightedEdge;
-import org.apache.commons.graph.model.BaseWeightedEdge;
+import org.apache.commons.graph.math.monoid.primitive.DoubleWeightBaseOperations;
import org.apache.commons.graph.model.MutableSpanningTree;
import org.apache.commons.graph.model.UndirectedMutableGraph;
-import org.apache.commons.graph.weight.primitive.DoubleWeightBaseOperations;
+import org.apache.commons.graph.model.labeled.BaseLabeledVertex;
+import org.apache.commons.graph.model.labeled.BaseLabeledWeightedEdge;
+import org.apache.commons.graph.model.labeled.BaseWeightedEdge;
import org.junit.Test;
public final class KruskalTestCase
Modified: commons/sandbox/graph/branches/modularization/spanning/src/test/java/org/apache/commons/graph/spanning/PrimTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/spanning/src/test/java/org/apache/commons/graph/spanning/PrimTestCase.java?rev=1486948&r1=1486620&r2=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/spanning/src/test/java/org/apache/commons/graph/spanning/PrimTestCase.java (original)
+++ commons/sandbox/graph/branches/modularization/spanning/src/test/java/org/apache/commons/graph/spanning/PrimTestCase.java Tue May 28 15:00:27 2013
@@ -19,18 +19,18 @@ package org.apache.commons.graph.spannin
* under the License.
*/
+import static org.apache.commons.graph.spanning.SpanningTreeSolver.minimumSpanningTree;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
-import static org.apache.commons.graph.CommonsGraph.minimumSpanningTree;
import org.apache.commons.graph.Graph;
import org.apache.commons.graph.SpanningTree;
-import org.apache.commons.graph.model.BaseLabeledVertex;
-import org.apache.commons.graph.model.BaseLabeledWeightedEdge;
-import org.apache.commons.graph.model.BaseWeightedEdge;
+import org.apache.commons.graph.math.monoid.primitive.DoubleWeightBaseOperations;
import org.apache.commons.graph.model.MutableSpanningTree;
import org.apache.commons.graph.model.UndirectedMutableGraph;
-import org.apache.commons.graph.weight.primitive.DoubleWeightBaseOperations;
+import org.apache.commons.graph.model.labeled.BaseLabeledVertex;
+import org.apache.commons.graph.model.labeled.BaseLabeledWeightedEdge;
+import org.apache.commons.graph.model.labeled.BaseWeightedEdge;
import org.junit.Test;
public final class PrimTestCase
Modified: commons/sandbox/graph/branches/modularization/spanning/src/test/java/org/apache/commons/graph/spanning/ReverseDeleteTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/spanning/src/test/java/org/apache/commons/graph/spanning/ReverseDeleteTestCase.java?rev=1486948&r1=1486620&r2=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/spanning/src/test/java/org/apache/commons/graph/spanning/ReverseDeleteTestCase.java (original)
+++ commons/sandbox/graph/branches/modularization/spanning/src/test/java/org/apache/commons/graph/spanning/ReverseDeleteTestCase.java Tue May 28 15:00:27 2013
@@ -19,17 +19,17 @@ package org.apache.commons.graph.spannin
* under the License.
*/
+import static org.apache.commons.graph.spanning.SpanningTreeSolver.minimumSpanningTree;
import static org.junit.Assert.assertEquals;
-import static org.apache.commons.graph.CommonsGraph.minimumSpanningTree;
import org.apache.commons.graph.Graph;
import org.apache.commons.graph.SpanningTree;
-import org.apache.commons.graph.model.BaseLabeledVertex;
-import org.apache.commons.graph.model.BaseLabeledWeightedEdge;
-import org.apache.commons.graph.model.BaseWeightedEdge;
+import org.apache.commons.graph.math.monoid.primitive.DoubleWeightBaseOperations;
import org.apache.commons.graph.model.MutableSpanningTree;
import org.apache.commons.graph.model.UndirectedMutableGraph;
-import org.apache.commons.graph.weight.primitive.DoubleWeightBaseOperations;
+import org.apache.commons.graph.model.labeled.BaseLabeledVertex;
+import org.apache.commons.graph.model.labeled.BaseLabeledWeightedEdge;
+import org.apache.commons.graph.model.labeled.BaseWeightedEdge;
import org.junit.Test;
/**
Propchange: commons/sandbox/graph/branches/modularization/visit/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue May 28 15:00:27 2013
@@ -0,0 +1,2 @@
+.settings
+target
Added: commons/sandbox/graph/branches/modularization/visit/pom.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/visit/pom.xml?rev=1486948&view=auto
==============================================================================
--- commons/sandbox/graph/branches/modularization/visit/pom.xml (added)
+++ commons/sandbox/graph/branches/modularization/visit/pom.xml Tue May 28 15:00:27 2013
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-graph</artifactId>
+ <version>0.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>commons-graph-visit</artifactId>
+
+ <name>Apache Commons Graph - Visit</name>
+ <description>Graph visit problem solver implementation.</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>${project.parent.groupId}</groupId>
+ <artifactId>commons-graph-api</artifactId>
+ <version>${project.parent.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.parent.groupId}</groupId>
+ <artifactId>commons-graph-model</artifactId>
+ <version>${project.parent.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <directory>${basedir}/../</directory>
+ <targetPath>META-INF</targetPath>
+ <includes>
+ <include>NOTICE.txt</include>
+ <include>LICENSE.txt</include>
+ </includes>
+ </resource>
+ </resources>
+ </build>
+
+</project>
Propchange: commons/sandbox/graph/branches/modularization/visit/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/graph/branches/modularization/visit/pom.xml
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: commons/sandbox/graph/branches/modularization/visit/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Modified: commons/sandbox/graph/branches/modularization/visit/src/main/java/org/apache/commons/graph/visit/DefaultVisitSourceSelector.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/visit/src/main/java/org/apache/commons/graph/visit/DefaultVisitSourceSelector.java?rev=1486948&r1=1486620&r2=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/visit/src/main/java/org/apache/commons/graph/visit/DefaultVisitSourceSelector.java (original)
+++ commons/sandbox/graph/branches/modularization/visit/src/main/java/org/apache/commons/graph/visit/DefaultVisitSourceSelector.java Tue May 28 15:00:27 2013
@@ -31,7 +31,7 @@ import org.apache.commons.graph.Graph;
* @param <E> the Graph edges type
* @param <G> the Graph type
*/
-public final class DefaultVisitSourceSelector<V, E, G extends Graph<V, E>>
+final class DefaultVisitSourceSelector<V, E, G extends Graph<V, E>>
implements VisitSourceSelector<V, E, G>
{
Added: commons/sandbox/graph/branches/modularization/visit/src/main/java/org/apache/commons/graph/visit/GraphVisitor.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/visit/src/main/java/org/apache/commons/graph/visit/GraphVisitor.java?rev=1486948&view=auto
==============================================================================
--- commons/sandbox/graph/branches/modularization/visit/src/main/java/org/apache/commons/graph/visit/GraphVisitor.java (added)
+++ commons/sandbox/graph/branches/modularization/visit/src/main/java/org/apache/commons/graph/visit/GraphVisitor.java Tue May 28 15:00:27 2013
@@ -0,0 +1,49 @@
+package org.apache.commons.graph.visit;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import static org.apache.commons.graph.utils.Assertions.checkNotNull;
+
+import org.apache.commons.graph.Graph;
+
+public final class GraphVisitor
+{
+
+ /**
+ * Allows select a series of algorithms to apply on input graph.
+ *
+ * @param <V> the Graph vertices type
+ * @param <E> the Graph edges type
+ * @param <G> the Graph type
+ * @param graph the Graph instance to apply graph algorithms
+ * @return the graph algorithms selector
+ */
+ public static <V, E, G extends Graph<V, E>> VisitSourceSelector<V, E, G> visit( G graph )
+ {
+ graph = checkNotNull( graph, "No algorithm can be applied on null graph!" );
+ return new DefaultVisitSourceSelector<V, E, G>( graph );
+ }
+
+ private GraphVisitor()
+ {
+ // do nothing
+ }
+
+}
Propchange: commons/sandbox/graph/branches/modularization/visit/src/main/java/org/apache/commons/graph/visit/GraphVisitor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/graph/branches/modularization/visit/src/main/java/org/apache/commons/graph/visit/GraphVisitor.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/graph/branches/modularization/visit/src/main/java/org/apache/commons/graph/visit/GraphVisitor.java
------------------------------------------------------------------------------
svn:mime-type = text/plain