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 [2/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...
Added: commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/DefaultLinkedConnectionBuilder.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/DefaultLinkedConnectionBuilder.java?rev=1486948&view=auto
==============================================================================
--- commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/DefaultLinkedConnectionBuilder.java (added)
+++ commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/DefaultLinkedConnectionBuilder.java Tue May 28 15:00:27 2013
@@ -0,0 +1,62 @@
+package org.apache.commons.graph.builder;
+
+/*
+ * 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.MutableGraph;
+
+/**
+ * TODO Fillme!!
+ *
+ * @param <V> the Graph vertices type
+ * @param <E> the Graph edges type
+ * @param <G> the Graph type
+ */
+public final class DefaultLinkedConnectionBuilder<V, E, G extends MutableGraph<V, E>>
+ implements LinkedConnectionBuilder<V, E, G>
+{
+
+ private final G graph;
+
+ /**
+ * Creates a new {@link DefaultLinkedConnectionBuilder} for the graph.
+ *
+ * @param graph the graph
+ */
+ public DefaultLinkedConnectionBuilder( G graph )
+ {
+ this.graph = graph;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public G withConnections( GraphConnection<V, E> graphConnection )
+ {
+ graphConnection = checkNotNull( graphConnection, "Input graph cannot be configured with null connections" );
+
+ GraphConnector<V, E> grapher = new DefaultGrapher<V, E>( graph );
+ graphConnection.connect( grapher );
+
+ return graph;
+ }
+
+}
Propchange: commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/DefaultLinkedConnectionBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/DefaultLinkedConnectionBuilder.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/DefaultLinkedConnectionBuilder.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/DefaultTailVertexConnector.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/DefaultTailVertexConnector.java?rev=1486948&view=auto
==============================================================================
--- commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/DefaultTailVertexConnector.java (added)
+++ commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/DefaultTailVertexConnector.java Tue May 28 15:00:27 2013
@@ -0,0 +1,49 @@
+package org.apache.commons.graph.builder;
+
+/*
+ * 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.MutableGraph;
+
+final class DefaultTailVertexConnector<V, E>
+ implements TailVertexConnector<V, E>
+{
+
+ private final MutableGraph<V, E> graph;
+
+ private final E edge;
+
+ private final V head;
+
+ public DefaultTailVertexConnector( MutableGraph<V, E> graph, E edge, V head )
+ {
+ this.graph = graph;
+ this.edge = edge;
+ this.head = head;
+ }
+
+ public <T extends V> void to( T tail )
+ {
+ tail = checkNotNull( tail, "Null tail vertex not admitted" );
+ graph.addEdge( head, edge, tail );
+ }
+
+}
Propchange: commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/DefaultTailVertexConnector.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/DefaultTailVertexConnector.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/DefaultTailVertexConnector.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/GraphConnection.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/GraphConnection.java?rev=1486948&view=auto
==============================================================================
--- commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/GraphConnection.java (added)
+++ commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/GraphConnection.java Tue May 28 15:00:27 2013
@@ -0,0 +1,38 @@
+package org.apache.commons.graph.builder;
+
+/*
+ * 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.
+ */
+
+/**
+ * TODO Fillme!!!
+ *
+ * @param <V> the Graph vertices type
+ * @param <E> the Graph edges type
+ */
+public interface GraphConnection<V, E>
+{
+
+ /**
+ * TODO Fillme!!
+ *
+ * @param grapher
+ */
+ void connect( GraphConnector<V, E> grapher );
+
+}
Propchange: commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/GraphConnection.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/GraphConnection.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/GraphConnection.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/GraphConnector.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/GraphConnector.java?rev=1486948&view=auto
==============================================================================
--- commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/GraphConnector.java (added)
+++ commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/GraphConnector.java Tue May 28 15:00:27 2013
@@ -0,0 +1,49 @@
+package org.apache.commons.graph.builder;
+
+/*
+ * 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.
+ */
+
+/**
+ * TODO Fillme!!
+ *
+ * @param <V> the Graph vertices type
+ * @param <E> the Graph edges type
+ */
+public interface GraphConnector<V, E>
+{
+
+ /**
+ * Adds a new vertex to graph.
+ *
+ * @param <N> the Graph vertices type
+ * @param node the vertex to add
+ * @return the vertex added
+ */
+ <N extends V> N addVertex( N node );
+
+ /**
+ * Adds a new edge to graph.
+ *
+ * @param <A> the Graph edges type
+ * @param arc the edge to add.
+ * @return the {@link HeadVertexConnector}
+ */
+ <A extends E> HeadVertexConnector<V, E> addEdge( A arc );
+
+}
Propchange: commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/GraphConnector.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/GraphConnector.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/GraphConnector.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/HeadVertexConnector.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/HeadVertexConnector.java?rev=1486948&view=auto
==============================================================================
--- commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/HeadVertexConnector.java (added)
+++ commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/HeadVertexConnector.java Tue May 28 15:00:27 2013
@@ -0,0 +1,40 @@
+package org.apache.commons.graph.builder;
+
+/*
+ * 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.
+ */
+
+/**
+ * TODO Fillme!!!
+ *
+ * @param <V> the Graph vertices type
+ * @param <E> the Graph edges type
+ */
+public interface HeadVertexConnector<V, E>
+{
+
+ /**
+ * Specifies the head vertex for the edge
+ *
+ * @param <H> the Graph vertex type
+ * @param head the head vertex
+ * @return {@link TailVertexConnector} builded from the head
+ */
+ <H extends V> TailVertexConnector<V, E> from( H head );
+
+}
Propchange: commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/HeadVertexConnector.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/HeadVertexConnector.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/HeadVertexConnector.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/LinkedConnectionBuilder.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/LinkedConnectionBuilder.java?rev=1486948&view=auto
==============================================================================
--- commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/LinkedConnectionBuilder.java (added)
+++ commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/LinkedConnectionBuilder.java Tue May 28 15:00:27 2013
@@ -0,0 +1,42 @@
+package org.apache.commons.graph.builder;
+
+/*
+ * 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 org.apache.commons.graph.MutableGraph;
+
+/**
+ * TODO Fillme!!!
+ *
+ * @param <V> the Graph vertices type
+ * @param <E> the Graph edges type
+ * @param <G> the Graph type
+ */
+public interface LinkedConnectionBuilder<V, E, G extends MutableGraph<V, E>>
+{
+
+ /**
+ * Connects the graph.
+ *
+ * @param graphConnection the {@link GraphConnection}
+ * @return the {@link org.apache.commons.graph.Graph} built from the connections.
+ */
+ G withConnections( GraphConnection<V, E> graphConnection );
+
+}
Propchange: commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/LinkedConnectionBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/LinkedConnectionBuilder.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/LinkedConnectionBuilder.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/TailVertexConnector.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/TailVertexConnector.java?rev=1486948&view=auto
==============================================================================
--- commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/TailVertexConnector.java (added)
+++ commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/TailVertexConnector.java Tue May 28 15:00:27 2013
@@ -0,0 +1,39 @@
+package org.apache.commons.graph.builder;
+
+/*
+ * 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.
+ */
+
+/**
+ * TODO Fillme!!!
+ *
+ * @param <V> the Graph vertices type
+ * @param <E> the Graph edges type
+ */
+public interface TailVertexConnector<V, E>
+{
+
+ /**
+ * Specifies the tail vertex for the edge
+ *
+ * @param <T> the Graph vertex type
+ * @param tail the tail vertex
+ */
+ <T extends V> void to( T tail );
+
+}
Propchange: commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/TailVertexConnector.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/TailVertexConnector.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/TailVertexConnector.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/package-info.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/package-info.java?rev=1486948&view=auto
==============================================================================
--- commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/package-info.java (added)
+++ commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/package-info.java Tue May 28 15:00:27 2013
@@ -0,0 +1,23 @@
+/**
+ * EDSL to build Graph instances using fluent APIs.
+ */
+package org.apache.commons.graph.builder;
+
+/*
+ * 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.
+ */
Propchange: commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/package-info.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/package-info.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/builder/package-info.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Copied: commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/math/monoid/Monoid.java (from r1486620, commons/sandbox/graph/branches/modularization/src/main/java/org/apache/commons/graph/weight/Monoid.java)
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/math/monoid/Monoid.java?p2=commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/math/monoid/Monoid.java&p1=commons/sandbox/graph/branches/modularization/src/main/java/org/apache/commons/graph/weight/Monoid.java&r1=1486620&r2=1486948&rev=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/src/main/java/org/apache/commons/graph/weight/Monoid.java (original)
+++ commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/math/monoid/Monoid.java Tue May 28 15:00:27 2013
@@ -1,4 +1,4 @@
-package org.apache.commons.graph.weight;
+package org.apache.commons.graph.math.monoid;
/*
* Licensed to the Apache Software Foundation (ASF) under one
Copied: commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/math/monoid/OrderedMonoid.java (from r1486620, commons/sandbox/graph/branches/modularization/src/main/java/org/apache/commons/graph/weight/OrderedMonoid.java)
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/math/monoid/OrderedMonoid.java?p2=commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/math/monoid/OrderedMonoid.java&p1=commons/sandbox/graph/branches/modularization/src/main/java/org/apache/commons/graph/weight/OrderedMonoid.java&r1=1486620&r2=1486948&rev=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/src/main/java/org/apache/commons/graph/weight/OrderedMonoid.java (original)
+++ commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/math/monoid/OrderedMonoid.java Tue May 28 15:00:27 2013
@@ -1,4 +1,4 @@
-package org.apache.commons.graph.weight;
+package org.apache.commons.graph.math.monoid;
/*
* Licensed to the Apache Software Foundation (ASF) under one
Copied: commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/math/monoid/package-info.java (from r1486620, commons/sandbox/graph/branches/modularization/src/main/java/org/apache/commons/graph/weight/package-info.java)
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/math/monoid/package-info.java?p2=commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/math/monoid/package-info.java&p1=commons/sandbox/graph/branches/modularization/src/main/java/org/apache/commons/graph/weight/package-info.java&r1=1486620&r2=1486948&rev=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/src/main/java/org/apache/commons/graph/weight/package-info.java (original)
+++ commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/math/monoid/package-info.java Tue May 28 15:00:27 2013
@@ -1,7 +1,7 @@
/**
* Interfaces that define properties and operations on weights.
*/
-package org.apache.commons.graph.weight;
+package org.apache.commons.graph.math.monoid;
/*
* Licensed to the Apache Software Foundation (ASF) under one
Modified: commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/math/monoid/primitive/BigDecimalWeightBaseOperations.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/math/monoid/primitive/BigDecimalWeightBaseOperations.java?rev=1486948&r1=1486620&r2=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/math/monoid/primitive/BigDecimalWeightBaseOperations.java (original)
+++ commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/math/monoid/primitive/BigDecimalWeightBaseOperations.java Tue May 28 15:00:27 2013
@@ -1,4 +1,4 @@
-package org.apache.commons.graph.weight.primitive;
+package org.apache.commons.graph.math.monoid.primitive;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -23,7 +23,7 @@ import static java.math.BigDecimal.ZERO;
import java.math.BigDecimal;
-import org.apache.commons.graph.weight.OrderedMonoid;
+import org.apache.commons.graph.math.monoid.OrderedMonoid;
/**
* The class {@link BigDecimalWeightBaseOperations} provides operations and properties
Modified: commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/math/monoid/primitive/BigIntegerWeightBaseOperations.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/math/monoid/primitive/BigIntegerWeightBaseOperations.java?rev=1486948&r1=1486620&r2=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/math/monoid/primitive/BigIntegerWeightBaseOperations.java (original)
+++ commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/math/monoid/primitive/BigIntegerWeightBaseOperations.java Tue May 28 15:00:27 2013
@@ -1,4 +1,4 @@
-package org.apache.commons.graph.weight.primitive;
+package org.apache.commons.graph.math.monoid.primitive;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -23,7 +23,7 @@ import static java.math.BigInteger.ZERO;
import java.math.BigInteger;
-import org.apache.commons.graph.weight.OrderedMonoid;
+import org.apache.commons.graph.math.monoid.OrderedMonoid;
/**
* The class {@link BigIntegerWeightBaseOperations} provides operations and properties
Modified: commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/math/monoid/primitive/DoubleWeightBaseOperations.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/math/monoid/primitive/DoubleWeightBaseOperations.java?rev=1486948&r1=1486620&r2=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/math/monoid/primitive/DoubleWeightBaseOperations.java (original)
+++ commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/math/monoid/primitive/DoubleWeightBaseOperations.java Tue May 28 15:00:27 2013
@@ -1,4 +1,4 @@
-package org.apache.commons.graph.weight.primitive;
+package org.apache.commons.graph.math.monoid.primitive;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,7 +19,7 @@ package org.apache.commons.graph.weight.
* under the License.
*/
-import org.apache.commons.graph.weight.OrderedMonoid;
+import org.apache.commons.graph.math.monoid.OrderedMonoid;
/**
* The class {@link DoubleWeightBaseOperations} provides operations and properties
Modified: commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/math/monoid/primitive/FloatWeightBaseOperations.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/math/monoid/primitive/FloatWeightBaseOperations.java?rev=1486948&r1=1486620&r2=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/math/monoid/primitive/FloatWeightBaseOperations.java (original)
+++ commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/math/monoid/primitive/FloatWeightBaseOperations.java Tue May 28 15:00:27 2013
@@ -1,4 +1,4 @@
-package org.apache.commons.graph.weight.primitive;
+package org.apache.commons.graph.math.monoid.primitive;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,7 +19,7 @@ package org.apache.commons.graph.weight.
* under the License.
*/
-import org.apache.commons.graph.weight.OrderedMonoid;
+import org.apache.commons.graph.math.monoid.OrderedMonoid;
/**
* The class {@link FloatWeightBaseOperations} provides operations and properties
Modified: commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/math/monoid/primitive/IntegerWeightBaseOperations.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/math/monoid/primitive/IntegerWeightBaseOperations.java?rev=1486948&r1=1486620&r2=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/math/monoid/primitive/IntegerWeightBaseOperations.java (original)
+++ commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/math/monoid/primitive/IntegerWeightBaseOperations.java Tue May 28 15:00:27 2013
@@ -1,4 +1,4 @@
-package org.apache.commons.graph.weight.primitive;
+package org.apache.commons.graph.math.monoid.primitive;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,7 +19,7 @@ package org.apache.commons.graph.weight.
* under the License.
*/
-import org.apache.commons.graph.weight.OrderedMonoid;
+import org.apache.commons.graph.math.monoid.OrderedMonoid;
/**
* The class {@link IntegerWeightBaseOperations} provides operations and properties
Modified: commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/math/monoid/primitive/LongWeightBaseOperations.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/math/monoid/primitive/LongWeightBaseOperations.java?rev=1486948&r1=1486620&r2=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/math/monoid/primitive/LongWeightBaseOperations.java (original)
+++ commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/math/monoid/primitive/LongWeightBaseOperations.java Tue May 28 15:00:27 2013
@@ -1,4 +1,4 @@
-package org.apache.commons.graph.weight.primitive;
+package org.apache.commons.graph.math.monoid.primitive;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,7 +19,7 @@ package org.apache.commons.graph.weight.
* under the License.
*/
-import org.apache.commons.graph.weight.OrderedMonoid;
+import org.apache.commons.graph.math.monoid.OrderedMonoid;
/**
* The class {@link LongWeightBaseOperations} provides operations and properties
Modified: commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/math/monoid/primitive/package-info.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/math/monoid/primitive/package-info.java?rev=1486948&r1=1486620&r2=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/math/monoid/primitive/package-info.java (original)
+++ commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/math/monoid/primitive/package-info.java Tue May 28 15:00:27 2013
@@ -1,7 +1,7 @@
/**
* Implementations of base operations on primitive types of weights.
*/
-package org.apache.commons.graph.weight.primitive;
+package org.apache.commons.graph.math.monoid.primitive;
/*
* Licensed to the Apache Software Foundation (ASF) under one
Added: commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/package-info.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/package-info.java?rev=1486948&view=auto
==============================================================================
--- commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/package-info.java (added)
+++ commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/package-info.java Tue May 28 15:00:27 2013
@@ -0,0 +1,23 @@
+/**
+ * Apache Commons Graph APIs.
+ */
+package org.apache.commons.graph;
+
+/*
+ * 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.
+ */
Propchange: commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/package-info.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/package-info.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/graph/branches/modularization/api/src/main/java/org/apache/commons/graph/package-info.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Propchange: commons/sandbox/graph/branches/modularization/benchmarks/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue May 28 15:00:27 2013
@@ -0,0 +1,2 @@
+.settings
+target
Added: commons/sandbox/graph/branches/modularization/benchmarks/pom.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/benchmarks/pom.xml?rev=1486948&view=auto
==============================================================================
--- commons/sandbox/graph/branches/modularization/benchmarks/pom.xml (added)
+++ commons/sandbox/graph/branches/modularization/benchmarks/pom.xml Tue May 28 15:00:27 2013
@@ -0,0 +1,115 @@
+<?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-benchmarks</artifactId>
+
+ <name>Apache Commons Graph - Benchmarks</name>
+ <description>Benchmarks across multiple Graph algorithms.</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>
+
+ <dependency>
+ <groupId>${project.parent.groupId}</groupId>
+ <artifactId>commons-graph-scc</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-spanning</artifactId>
+ <version>${project.parent.version}</version>
+ </dependency>
+
+ <!-- test 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>
+ <resources>
+ <resource>
+ <directory>${basedir}/../</directory>
+ <targetPath>META-INF</targetPath>
+ <includes>
+ <include>NOTICE.txt</include>
+ <include>LICENSE.txt</include>
+ </includes>
+ </resource>
+ </resources>
+
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemPropertyVariables>
+ <jub.consumers>CONSOLE,XML,H2</jub.consumers>
+ <jub.db.file>${project.parent.build.directory}/benchmarks/database</jub.db.file>
+ <jub.xml.file>${project.parent.build.directory}/benchmarks.xml</jub.xml.file>
+ <jub.charts.dir>${project.parent.build.directory}/site/benchmarks</jub.charts.dir>
+ </systemPropertyVariables>
+ <argLine>-Xmx512m -Xms512m</argLine>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
Propchange: commons/sandbox/graph/branches/modularization/benchmarks/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/graph/branches/modularization/benchmarks/pom.xml
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: commons/sandbox/graph/branches/modularization/benchmarks/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Modified: commons/sandbox/graph/branches/modularization/benchmarks/src/test/java/org/apache/commons/graph/scc/SCCAlgorithmBenchmarkTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/benchmarks/src/test/java/org/apache/commons/graph/scc/SCCAlgorithmBenchmarkTestCase.java?rev=1486948&r1=1486620&r2=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/benchmarks/src/test/java/org/apache/commons/graph/scc/SCCAlgorithmBenchmarkTestCase.java (original)
+++ commons/sandbox/graph/branches/modularization/benchmarks/src/test/java/org/apache/commons/graph/scc/SCCAlgorithmBenchmarkTestCase.java Tue May 28 15:00:27 2013
@@ -21,8 +21,8 @@ package org.apache.commons.graph.scc;
import static java.lang.String.format;
import static java.lang.String.valueOf;
-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.assertTrue;
import java.util.ArrayList;
@@ -32,9 +32,9 @@ import java.util.Set;
import org.apache.commons.graph.GraphException;
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.DirectedMutableGraph;
+import org.apache.commons.graph.model.labeled.BaseLabeledEdge;
+import org.apache.commons.graph.model.labeled.BaseLabeledVertex;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
Modified: commons/sandbox/graph/branches/modularization/benchmarks/src/test/java/org/apache/commons/graph/shortestpath/UniVsBiDijkstraBenchmarkTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/benchmarks/src/test/java/org/apache/commons/graph/shortestpath/UniVsBiDijkstraBenchmarkTestCase.java?rev=1486948&r1=1486620&r2=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/benchmarks/src/test/java/org/apache/commons/graph/shortestpath/UniVsBiDijkstraBenchmarkTestCase.java (original)
+++ commons/sandbox/graph/branches/modularization/benchmarks/src/test/java/org/apache/commons/graph/shortestpath/UniVsBiDijkstraBenchmarkTestCase.java Tue May 28 15:00:27 2013
@@ -21,8 +21,8 @@ package org.apache.commons.graph.shortes
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.assertTrue;
import java.util.ArrayList;
@@ -30,17 +30,16 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Random;
-import org.apache.commons.graph.builder.AbstractGraphConnection;
import org.apache.commons.graph.GraphException;
import org.apache.commons.graph.Mapper;
-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.model.DirectedMutableGraph;
import org.apache.commons.graph.WeightedPath;
-import org.apache.commons.graph.weight.OrderedMonoid;
-import org.apache.commons.graph.weight.primitive.DoubleWeightBaseOperations;
-
+import org.apache.commons.graph.builder.AbstractGraphConnection;
+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.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.Rule;
import org.junit.Test;
Modified: commons/sandbox/graph/branches/modularization/benchmarks/src/test/java/org/apache/commons/graph/spanning/MinimumSpanningTreeBenchmarkTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/benchmarks/src/test/java/org/apache/commons/graph/spanning/MinimumSpanningTreeBenchmarkTestCase.java?rev=1486948&r1=1486620&r2=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/benchmarks/src/test/java/org/apache/commons/graph/spanning/MinimumSpanningTreeBenchmarkTestCase.java (original)
+++ commons/sandbox/graph/branches/modularization/benchmarks/src/test/java/org/apache/commons/graph/spanning/MinimumSpanningTreeBenchmarkTestCase.java Tue May 28 15:00:27 2013
@@ -21,8 +21,8 @@ package org.apache.commons.graph.spannin
import static java.lang.String.format;
import static java.lang.String.valueOf;
-import static org.apache.commons.graph.CommonsGraph.minimumSpanningTree;
-import static org.apache.commons.graph.CommonsGraph.newUndirectedMutableGraph;
+import static org.apache.commons.graph.model.GraphUtils.newUndirectedMutableGraph;
+import static org.apache.commons.graph.spanning.SpanningTreeSolver.minimumSpanningTree;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
@@ -33,10 +33,10 @@ import org.apache.commons.graph.GraphExc
import org.apache.commons.graph.Mapper;
import org.apache.commons.graph.SpanningTree;
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.primitive.DoubleWeightBaseOperations;
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.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
Propchange: commons/sandbox/graph/branches/modularization/collections/disjoint-set/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue May 28 15:00:27 2013
@@ -0,0 +1,2 @@
+target
+.settings
Added: commons/sandbox/graph/branches/modularization/collections/disjoint-set/pom.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/collections/disjoint-set/pom.xml?rev=1486948&view=auto
==============================================================================
--- commons/sandbox/graph/branches/modularization/collections/disjoint-set/pom.xml (added)
+++ commons/sandbox/graph/branches/modularization/collections/disjoint-set/pom.xml Tue May 28 15:00:27 2013
@@ -0,0 +1,46 @@
+<?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>
+ <relativePath>../../</relativePath>
+ </parent>
+
+ <artifactId>commons-graph-disjointset</artifactId>
+
+ <name>Apache Commons Graph - Collections - Disjoint Set</name>
+ <description>Disjoint Set data structure implementation.</description>
+
+ <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/collections/disjoint-set/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/graph/branches/modularization/collections/disjoint-set/pom.xml
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: commons/sandbox/graph/branches/modularization/collections/disjoint-set/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: commons/sandbox/graph/branches/modularization/collections/disjoint-set/src/main/java/org/apache/commons/graph/collections/package-info.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/collections/disjoint-set/src/main/java/org/apache/commons/graph/collections/package-info.java?rev=1486948&view=auto
==============================================================================
--- commons/sandbox/graph/branches/modularization/collections/disjoint-set/src/main/java/org/apache/commons/graph/collections/package-info.java (added)
+++ commons/sandbox/graph/branches/modularization/collections/disjoint-set/src/main/java/org/apache/commons/graph/collections/package-info.java Tue May 28 15:00:27 2013
@@ -0,0 +1,23 @@
+/**
+ * Simple <a href="http://en.wikipedia.org/wiki/Disjoint-set_data_structure">Disjoint-set</a> implementation.
+ */
+package org.apache.commons.graph.collections;
+
+/*
+ * 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.
+ */
Propchange: commons/sandbox/graph/branches/modularization/collections/disjoint-set/src/main/java/org/apache/commons/graph/collections/package-info.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/graph/branches/modularization/collections/disjoint-set/src/main/java/org/apache/commons/graph/collections/package-info.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/graph/branches/modularization/collections/disjoint-set/src/main/java/org/apache/commons/graph/collections/package-info.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Propchange: commons/sandbox/graph/branches/modularization/collections/fibonacci-heap/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue May 28 15:00:27 2013
@@ -0,0 +1,2 @@
+target
+.settings
Added: commons/sandbox/graph/branches/modularization/collections/fibonacci-heap/pom.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/collections/fibonacci-heap/pom.xml?rev=1486948&view=auto
==============================================================================
--- commons/sandbox/graph/branches/modularization/collections/fibonacci-heap/pom.xml (added)
+++ commons/sandbox/graph/branches/modularization/collections/fibonacci-heap/pom.xml Tue May 28 15:00:27 2013
@@ -0,0 +1,46 @@
+<?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>
+ <relativePath>../../</relativePath>
+ </parent>
+
+ <artifactId>commons-graph-fibonacciheap</artifactId>
+
+ <name>Apache Commons Graph - Collections - Fibonacci Heap</name>
+ <description>Fibonacci Heap data structure implementation.</description>
+
+ <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/collections/fibonacci-heap/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/graph/branches/modularization/collections/fibonacci-heap/pom.xml
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: commons/sandbox/graph/branches/modularization/collections/fibonacci-heap/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Copied: commons/sandbox/graph/branches/modularization/collections/fibonacci-heap/src/main/java/org/apache/commons/graph/collections/FibonacciHeap.java (from r1486530, commons/sandbox/graph/branches/modularization/src/main/java/org/apache/commons/graph/collections/FibonacciHeap.java)
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/collections/fibonacci-heap/src/main/java/org/apache/commons/graph/collections/FibonacciHeap.java?p2=commons/sandbox/graph/branches/modularization/collections/fibonacci-heap/src/main/java/org/apache/commons/graph/collections/FibonacciHeap.java&p1=commons/sandbox/graph/branches/modularization/src/main/java/org/apache/commons/graph/collections/FibonacciHeap.java&r1=1486530&r2=1486948&rev=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/src/main/java/org/apache/commons/graph/collections/FibonacciHeap.java (original)
+++ commons/sandbox/graph/branches/modularization/collections/fibonacci-heap/src/main/java/org/apache/commons/graph/collections/FibonacciHeap.java Tue May 28 15:00:27 2013
@@ -19,8 +19,6 @@ package org.apache.commons.graph.collect
* under the License.
*/
-import static org.apache.commons.graph.utils.Assertions.checkNotNull;
-
import static java.lang.Math.floor;
import static java.lang.Math.log;
import static java.lang.Math.sqrt;
@@ -127,7 +125,7 @@ public final class FibonacciHeap<E>
// 7 concatenate the root list containing x with root list H
node.getLeft().setRight( node.getRight() );
node.getRight().setLeft( node.getLeft() );
-
+
node.setLeft( minimumNode );
node.setRight( minimumNode.getRight() );
minimumNode.setRight( node );
@@ -159,7 +157,10 @@ public final class FibonacciHeap<E>
*/
public boolean add( E e )
{
- checkNotNull( e, "Null elements not allowed in this FibonacciHeap implementation." );
+ if ( e == null )
+ {
+ throw new IllegalArgumentException( "Null elements not allowed in this FibonacciHeap implementation." );
+ }
// 1-6 performed in the node initialization
FibonacciHeapNode<E> node = new FibonacciHeapNode<E>( e );
Added: commons/sandbox/graph/branches/modularization/collections/fibonacci-heap/src/main/java/org/apache/commons/graph/collections/package-info.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/collections/fibonacci-heap/src/main/java/org/apache/commons/graph/collections/package-info.java?rev=1486948&view=auto
==============================================================================
--- commons/sandbox/graph/branches/modularization/collections/fibonacci-heap/src/main/java/org/apache/commons/graph/collections/package-info.java (added)
+++ commons/sandbox/graph/branches/modularization/collections/fibonacci-heap/src/main/java/org/apache/commons/graph/collections/package-info.java Tue May 28 15:00:27 2013
@@ -0,0 +1,25 @@
+/**
+ * A Fibonacci Heap implementation based on
+ * <a href="http://staff.ustc.edu.cn/~csli/graduate/algorithms/book6/chap21.htm">University of Science and Technology of
+ * China</a> lesson.
+ */
+package org.apache.commons.graph.collections;
+
+/*
+ * 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.
+ */
Propchange: commons/sandbox/graph/branches/modularization/collections/fibonacci-heap/src/main/java/org/apache/commons/graph/collections/package-info.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/graph/branches/modularization/collections/fibonacci-heap/src/main/java/org/apache/commons/graph/collections/package-info.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/graph/branches/modularization/collections/fibonacci-heap/src/main/java/org/apache/commons/graph/collections/package-info.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Copied: commons/sandbox/graph/branches/modularization/collections/fibonacci-heap/src/test/java/org/apache/commons/graph/collections/FibonacciHeapTestCase.java (from r1486530, commons/sandbox/graph/branches/modularization/src/test/java/org/apache/commons/graph/collections/FibonacciHeapTestCase.java)
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/collections/fibonacci-heap/src/test/java/org/apache/commons/graph/collections/FibonacciHeapTestCase.java?p2=commons/sandbox/graph/branches/modularization/collections/fibonacci-heap/src/test/java/org/apache/commons/graph/collections/FibonacciHeapTestCase.java&p1=commons/sandbox/graph/branches/modularization/src/test/java/org/apache/commons/graph/collections/FibonacciHeapTestCase.java&r1=1486530&r2=1486948&rev=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/src/test/java/org/apache/commons/graph/collections/FibonacciHeapTestCase.java (original)
+++ commons/sandbox/graph/branches/modularization/collections/fibonacci-heap/src/test/java/org/apache/commons/graph/collections/FibonacciHeapTestCase.java Tue May 28 15:00:27 2013
@@ -141,7 +141,7 @@ public final class FibonacciHeapTestCase
Integer i = queue.poll();
assertThat( i, is( integer ) );
}
-
+
assertThat( queue.isEmpty(), is( true ) );
}
@@ -149,17 +149,17 @@ public final class FibonacciHeapTestCase
public void addAllAndContinsItem()
{
Collection<Integer> c = new ArrayList<Integer>();
-
+
c.add( 50 );
c.add( 100 );
c.add( 20 );
c.add( 21 );
queue.addAll( c );
-
+
assertThat( queue.isEmpty(), is( false ) );
assertThat( queue.containsAll( c ), is( true ) );
-
+
assertThat( queue.contains( 100 ), is( true ) );
assertThat( queue.contains( 21 ), is( true ) );
assertThat( queue.contains( 50 ), is( true ) );
@@ -194,10 +194,11 @@ public final class FibonacciHeapTestCase
assertThat( queue.element(), is( 20 ) );
assertThat( queue.size(), is( 4 ) );
}
-
+
@Test( expected = NoSuchElementException.class )
public void elementThrowsException()
{
queue.element();
}
+
}
Propchange: commons/sandbox/graph/branches/modularization/coloring/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue May 28 15:00:27 2013
@@ -0,0 +1,2 @@
+.settings
+target
Added: commons/sandbox/graph/branches/modularization/coloring/pom.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/coloring/pom.xml?rev=1486948&view=auto
==============================================================================
--- commons/sandbox/graph/branches/modularization/coloring/pom.xml (added)
+++ commons/sandbox/graph/branches/modularization/coloring/pom.xml Tue May 28 15:00:27 2013
@@ -0,0 +1,60 @@
+<?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-coloring</artifactId>
+
+ <name>Apache Commons Graph - Coloring</name>
+ <description>Graph coloring 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>
+ <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/coloring/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/graph/branches/modularization/coloring/pom.xml
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: commons/sandbox/graph/branches/modularization/coloring/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: commons/sandbox/graph/branches/modularization/coloring/src/main/java/org/apache/commons/graph/coloring/ColoringSolver.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/coloring/src/main/java/org/apache/commons/graph/coloring/ColoringSolver.java?rev=1486948&view=auto
==============================================================================
--- commons/sandbox/graph/branches/modularization/coloring/src/main/java/org/apache/commons/graph/coloring/ColoringSolver.java (added)
+++ commons/sandbox/graph/branches/modularization/coloring/src/main/java/org/apache/commons/graph/coloring/ColoringSolver.java Tue May 28 15:00:27 2013
@@ -0,0 +1,49 @@
+package org.apache.commons.graph.coloring;
+
+/*
+ * 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.UndirectedGraph;
+
+public final class ColoringSolver
+{
+
+ private ColoringSolver()
+ {
+ // do nothing
+ }
+
+ /**
+ * Create a color builder.
+ *
+ * @param <V> the Graph vertices type
+ * @param <E> the Graph edges type
+ * @param <G> the Graph type
+ * @param graph the input graph
+ * @return an instance of {@link ColorsBuilder}
+ */
+ public static <V, E, G extends UndirectedGraph<V, E>> ColorsBuilder<V, E> coloring( G graph )
+ {
+ graph = checkNotNull( graph, "Coloring can not be calculated on null graph" );
+ return new DefaultColorsBuilder<V, E>( graph );
+ }
+
+}
Propchange: commons/sandbox/graph/branches/modularization/coloring/src/main/java/org/apache/commons/graph/coloring/ColoringSolver.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/graph/branches/modularization/coloring/src/main/java/org/apache/commons/graph/coloring/ColoringSolver.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/graph/branches/modularization/coloring/src/main/java/org/apache/commons/graph/coloring/ColoringSolver.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: commons/sandbox/graph/branches/modularization/coloring/src/main/java/org/apache/commons/graph/coloring/DefaultColorsBuilder.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/coloring/src/main/java/org/apache/commons/graph/coloring/DefaultColorsBuilder.java?rev=1486948&r1=1486620&r2=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/coloring/src/main/java/org/apache/commons/graph/coloring/DefaultColorsBuilder.java (original)
+++ commons/sandbox/graph/branches/modularization/coloring/src/main/java/org/apache/commons/graph/coloring/DefaultColorsBuilder.java Tue May 28 15:00:27 2013
@@ -31,7 +31,7 @@ import org.apache.commons.graph.Undirect
* @param <V> the Graph vertices type
* @param <E> the Graph edges type
*/
-public final class DefaultColorsBuilder<V, E>
+final class DefaultColorsBuilder<V, E>
implements ColorsBuilder<V, E>
{
Modified: commons/sandbox/graph/branches/modularization/coloring/src/test/java/org/apache/commons/graph/coloring/AbstractColoringTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/coloring/src/test/java/org/apache/commons/graph/coloring/AbstractColoringTest.java?rev=1486948&r1=1486620&r2=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/coloring/src/test/java/org/apache/commons/graph/coloring/AbstractColoringTest.java (original)
+++ commons/sandbox/graph/branches/modularization/coloring/src/test/java/org/apache/commons/graph/coloring/AbstractColoringTest.java Tue May 28 15:00:27 2013
@@ -19,17 +19,25 @@ package org.apache.commons.graph.colorin
* under the License.
*/
+import static java.lang.String.format;
+import static java.lang.String.valueOf;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
+import org.apache.commons.graph.GraphException;
import org.apache.commons.graph.VertexPair;
+import org.apache.commons.graph.model.BaseMutableGraph;
import org.apache.commons.graph.model.UndirectedMutableGraph;
+import org.apache.commons.graph.model.labeled.BaseLabeledEdge;
+import org.apache.commons.graph.model.labeled.BaseLabeledVertex;
/**
* Abstract class used for test coloring.
@@ -37,14 +45,10 @@ import org.apache.commons.graph.model.Un
abstract class AbstractColoringTest
{
- AbstractColoringTest()
- {
- }
-
/**
* Return a random association with index and a color string in RGB.
*/
- protected Map<Integer, String> createColorMap( int numColor )
+ protected static Map<Integer, String> createColorMap( int numColor )
{
Map<Integer, String> colorCodes = new HashMap<Integer, String>();
for ( int i = 0; i < 100; i++ )
@@ -61,7 +65,7 @@ abstract class AbstractColoringTest
* @param colorNumber number of colors
* @return the list.
*/
- protected Set<Integer> createColorsList( int colorNumber )
+ protected static Set<Integer> createColorsList( int colorNumber )
{
Set<Integer> colors = new HashSet<Integer>();
for ( int j = 0; j < colorNumber; j++ )
@@ -77,8 +81,8 @@ abstract class AbstractColoringTest
* @param g
* @param coloredVertices
*/
- protected <V, E, C> void checkColoring( UndirectedMutableGraph<V, E> g,
- ColoredVertices<V, C> coloredVertices )
+ protected static <V, E, C> void checkColoring( UndirectedMutableGraph<V, E> g,
+ ColoredVertices<V, C> coloredVertices )
{
for ( E e : g.getEdges() )
{
@@ -92,4 +96,240 @@ abstract class AbstractColoringTest
}
}
+ /**
+ * Create a Biparted graph
+ *
+ * @param nVertices number of vertices
+ * @param g graph
+ */
+ protected static void buildBipartedGraph( int nVertices, UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledEdge> g )
+ {
+ // building Graph
+ for ( int i = 0; i < nVertices; i++ )
+ {
+ BaseLabeledVertex v = new BaseLabeledVertex( valueOf( i ) );
+ g.addVertex( v );
+ }
+
+ List<BaseLabeledVertex> fistPartition = new ArrayList<BaseLabeledVertex>();
+ List<BaseLabeledVertex> secondPartition = new ArrayList<BaseLabeledVertex>();
+
+ int count = 0;
+ for ( BaseLabeledVertex v1 : g.getVertices() )
+ {
+ if ( count++ == nVertices / 2 )
+ {
+ break;
+ }
+ fistPartition.add( v1 );
+ }
+
+ count = 0;
+ for ( BaseLabeledVertex v2 : g.getVertices() )
+ {
+ if ( count++ < nVertices / 2 )
+ {
+ continue;
+ }
+ secondPartition.add( v2 );
+ }
+
+ for ( BaseLabeledVertex v1 : fistPartition )
+ {
+ for ( BaseLabeledVertex v2 : secondPartition )
+ {
+ if ( !v1.equals( v2 ) )
+ {
+ try
+ {
+ g.addEdge( v1, new BaseLabeledEdge( format( "%s -> %s", v1, v2 ) ), v2 );
+ }
+ catch ( GraphException e )
+ {
+ // ignore
+ }
+ }
+ }
+ }
+ }
+
+ protected static void buildCrownGraph( int nVertices, UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledEdge> g )
+ {
+ List<BaseLabeledVertex> tmp = new ArrayList<BaseLabeledVertex>();
+
+ for ( int i = 0; i < nVertices; i++ )
+ {
+ BaseLabeledVertex v = new BaseLabeledVertex( valueOf( i ) );
+ g.addVertex( v );
+ tmp.add( v );
+ }
+
+ for ( int i = 0; i < nVertices; i++ )
+ {
+ int next = i + 1;
+ if ( i == ( nVertices - 1 ) )
+ {
+ next = 0;
+ }
+ BaseLabeledEdge e = new BaseLabeledEdge( format( "%s -> %s", i, next ) );
+ try
+ {
+ g.addEdge( tmp.get( i ), e, tmp.get( next ) );
+ }
+ catch ( GraphException ge )
+ {
+ // ignore
+ }
+ }
+ }
+
+ /**
+ * Creates a graph that contains all classic sudoku contratints.
+ *
+ * @return
+ */
+ protected static BaseLabeledVertex[][] buildSudokuGraph( UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledEdge> sudoku )
+ {
+ BaseLabeledVertex[][] grid = new BaseLabeledVertex[9][9];
+ // build sudoku grid.
+ for ( int row = 0; row < 9; row++ )
+ {
+ for ( int col = 0; col < 9; col++ )
+ {
+ grid[row][col] = new BaseLabeledVertex( format( "%s, %s", row, col ) );
+ sudoku.addVertex( grid[row][col] );
+ }
+ }
+
+ int[] rowsOffsets = new int[] { 0, 3, 6 };
+ int[] colsOffsets = new int[] { 0, 3, 6 };
+
+ // build constraint.
+ for ( int rof = 0; rof < 3; rof++ )
+ {
+ for ( int cof = 0; cof < 3; cof++ )
+ {
+ List<BaseLabeledVertex> boxes = new ArrayList<BaseLabeledVertex>();
+ for ( int row = rowsOffsets[rof]; row < 3 + rowsOffsets[rof]; row++ )
+ {
+ for ( int col = colsOffsets[cof]; col < 3 + colsOffsets[cof]; col++ )
+ {
+ boxes.add( grid[row][col] );
+ }
+ }
+
+ for ( BaseLabeledVertex v1 : boxes )
+ {
+ for ( BaseLabeledVertex v2 : boxes )
+ {
+
+ BaseLabeledEdge e = new BaseLabeledEdge( format( "%s -> %s", v1, v2 ) );
+ if ( !v1.equals( v2 ) )
+ {
+ try
+ {
+ sudoku.addEdge( v1, e, v2 );
+ }
+ catch ( GraphException ge )
+ {
+ // ignore
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // create rows constraint
+ for ( int j = 0; j < 9; j++ )
+ {
+ for ( int i = 0; i < 9; i++ )
+ {
+ for ( int h = 0; h < 9; h++ )
+ {
+ BaseLabeledVertex v1 = grid[j][i];
+ BaseLabeledVertex v2 = grid[j][h];
+
+ if ( !v1.equals( v2 ) )
+ {
+ BaseLabeledEdge e = new BaseLabeledEdge( format( "%s -> %s", v1, v2 ) );
+ try
+ {
+ sudoku.addEdge( v1, e, v2 );
+ }
+ catch ( GraphException ge )
+ {
+ // ignore
+ }
+ }
+
+ }
+ }
+ }
+
+ // create cols constraint
+ for ( int j = 0; j < 9; j++ )
+ {
+ for ( int i = 0; i < 9; i++ )
+ {
+ for ( int h = 0; h < 9; h++ )
+ {
+ BaseLabeledVertex v1 = grid[i][j];
+ BaseLabeledVertex v2 = grid[h][j];
+
+ if ( !v1.equals( v2 ) )
+ {
+ BaseLabeledEdge e = new BaseLabeledEdge( format( "%s -> %s", v1, v2 ) );
+ try
+ {
+ sudoku.addEdge( v1, e, v2 );
+ }
+ catch ( GraphException ge )
+ {
+ // ignore
+ }
+ }
+
+ }
+ }
+ }
+ return grid;
+ }
+
+
+
+ /**
+ * Creates a complete graph with nVertices
+ *
+ * @param nVertices number of vertices
+ * @param g graph
+ */
+ protected static void buildCompleteGraph( int nVertices, BaseMutableGraph<BaseLabeledVertex, BaseLabeledEdge> g )
+ {
+ // building Graph
+ for ( int i = 0; i < nVertices; i++ )
+ {
+ BaseLabeledVertex v = new BaseLabeledVertex( valueOf( i ) );
+ g.addVertex( v );
+ }
+
+ for ( BaseLabeledVertex v1 : g.getVertices() )
+ {
+ for ( BaseLabeledVertex v2 : g.getVertices() )
+ {
+ if ( !v1.equals( v2 ) )
+ {
+ try
+ {
+ g.addEdge( v1, new BaseLabeledEdge( format( "%s -> %s", v1, v2 ) ), v2 );
+ }
+ catch ( GraphException e )
+ {
+ // ignore
+ }
+ }
+ }
+ }
+ }
+
}
Modified: commons/sandbox/graph/branches/modularization/coloring/src/test/java/org/apache/commons/graph/coloring/GraphColoringBackTrackingTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/modularization/coloring/src/test/java/org/apache/commons/graph/coloring/GraphColoringBackTrackingTestCase.java?rev=1486948&r1=1486620&r2=1486948&view=diff
==============================================================================
--- commons/sandbox/graph/branches/modularization/coloring/src/test/java/org/apache/commons/graph/coloring/GraphColoringBackTrackingTestCase.java (original)
+++ commons/sandbox/graph/branches/modularization/coloring/src/test/java/org/apache/commons/graph/coloring/GraphColoringBackTrackingTestCase.java Tue May 28 15:00:27 2013
@@ -19,12 +19,8 @@ package org.apache.commons.graph.colorin
* under the License.
*/
-import static org.apache.commons.graph.CommonsGraph.coloring;
-import static org.apache.commons.graph.CommonsGraph.newUndirectedMutableGraph;
-import static org.apache.commons.graph.utils.GraphUtils.buildBipartedGraph;
-import static org.apache.commons.graph.utils.GraphUtils.buildCompleteGraph;
-import static org.apache.commons.graph.utils.GraphUtils.buildCrownGraph;
-import static org.apache.commons.graph.utils.GraphUtils.buildSudokuGraph;
+import static org.apache.commons.graph.Graphs.populate;
+import static org.apache.commons.graph.coloring.ColoringSolver.coloring;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -34,10 +30,10 @@ import java.util.logging.Logger;
import org.apache.commons.graph.UndirectedGraph;
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.UndirectedMutableGraph;
+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;
/**
@@ -80,22 +76,23 @@ public class GraphColoringBackTrackingTe
final BaseLabeledVertex two = new BaseLabeledVertex( "2" );
UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledEdge> g =
- newUndirectedMutableGraph( new AbstractGraphConnection<BaseLabeledVertex, BaseLabeledEdge>()
- {
+ populate( new UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledEdge>() )
+ .withConnections( new AbstractGraphConnection<BaseLabeledVertex, BaseLabeledEdge>()
+ {
- @Override
- public void connect()
- {
- BaseLabeledVertex one = addVertex( new BaseLabeledVertex( "1" ) );
- addVertex( two );
- BaseLabeledVertex three = addVertex( new BaseLabeledVertex( "3" ) );
-
- addEdge( new BaseLabeledEdge( "1 -> 2" ) ).from( one ).to( two );
- addEdge( new BaseLabeledEdge( "2 -> 3" ) ).from( two ).to( three );
- addEdge( new BaseLabeledEdge( "3 -> 1" ) ).from( three ).to( one );
- }
+ @Override
+ public void connect()
+ {
+ BaseLabeledVertex one = addVertex( new BaseLabeledVertex( "1" ) );
+ addVertex( two );
+ BaseLabeledVertex three = addVertex( new BaseLabeledVertex( "3" ) );
+
+ addEdge( new BaseLabeledEdge( "1 -> 2" ) ).from( one ).to( two );
+ addEdge( new BaseLabeledEdge( "2 -> 3" ) ).from( two ).to( three );
+ addEdge( new BaseLabeledEdge( "3 -> 1" ) ).from( three ).to( one );
+ }
- } );
+ } );
coloring( g ).withColors( createColorsList( 1 ) ).applyingBackTrackingAlgorithm();
}
@@ -105,22 +102,23 @@ public class GraphColoringBackTrackingTe
final BaseLabeledVertex two = new BaseLabeledVertex( "2" );
UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledEdge> g =
- newUndirectedMutableGraph( new AbstractGraphConnection<BaseLabeledVertex, BaseLabeledEdge>()
- {
+ populate( new UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledEdge>() )
+ .withConnections( new AbstractGraphConnection<BaseLabeledVertex, BaseLabeledEdge>()
+ {
- @Override
- public void connect()
- {
- BaseLabeledVertex one = addVertex( new BaseLabeledVertex( "1" ) );
- addVertex( two );
- BaseLabeledVertex three = addVertex( new BaseLabeledVertex( "3" ) );
-
- addEdge( new BaseLabeledEdge( "1 -> 2" ) ).from( one ).to( two );
- addEdge( new BaseLabeledEdge( "2 -> 3" ) ).from( two ).to( three );
- addEdge( new BaseLabeledEdge( "3 -> 1" ) ).from( three ).to( one );
- }
+ @Override
+ public void connect()
+ {
+ BaseLabeledVertex one = addVertex( new BaseLabeledVertex( "1" ) );
+ addVertex( two );
+ BaseLabeledVertex three = addVertex( new BaseLabeledVertex( "3" ) );
+
+ addEdge( new BaseLabeledEdge( "1 -> 2" ) ).from( one ).to( two );
+ addEdge( new BaseLabeledEdge( "2 -> 3" ) ).from( two ).to( three );
+ addEdge( new BaseLabeledEdge( "3 -> 1" ) ).from( three ).to( one );
+ }
- } );
+ } );
ColoredVertices<BaseLabeledVertex, Integer> coloredVertex = new ColoredVertices<BaseLabeledVertex, Integer>();
coloredVertex.addColor( two, 2 );
@@ -265,7 +263,6 @@ public class GraphColoringBackTrackingTe
sb.append( "\n" );
}
Logger.getAnonymousLogger().fine( sb.toString() );
-
}
}