Author: marcosperanza
Date: Sun Feb 19 13:21:23 2012
New Revision: 1290996
URL: http://svn.apache.org/viewvc?rev=1290996&view=rev
Log:
Added check for monoid input argument
Modified:
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/DefaultSpanningTreeAlgorithmSelector.java
Modified:
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/DefaultSpanningTreeAlgorithmSelector.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/DefaultSpanningTreeAlgorithmSelector.java?rev=1290996&r1=1290995&r2=1290996&view=diff
==============================================================================
---
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/DefaultSpanningTreeAlgorithmSelector.java
(original)
+++
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/DefaultSpanningTreeAlgorithmSelector.java
Sun Feb 19 13:21:23 2012
@@ -20,6 +20,8 @@ package org.apache.commons.graph.spannin
*/
import static org.apache.commons.graph.utils.Assertions.checkState;
+import static org.apache.commons.graph.utils.Assertions.checkNotNull;
+
import java.util.HashMap;
import java.util.HashSet;
@@ -77,7 +79,7 @@ final class DefaultSpanningTreeAlgorithm
* end while
* <pre>
*/
-
+ checkNotNull( orderedMonoid, "The Boruvka algorithm can't be calulated
with a null monoid" );
final MutableSpanningTree<V, WE, W> spanningTree =
new MutableSpanningTree<V, WE, W>( orderedMonoid );
@@ -157,6 +159,8 @@ final class DefaultSpanningTreeAlgorithm
*/
public <OM extends OrderedMonoid<W>> SpanningTree<V, WE, W>
applyingKruskalAlgorithm( OM orderedMonoid )
{
+
+ checkNotNull( orderedMonoid, "The Kruskal algorithm can't be calulated
with a null monoid" );
final Set<V> settledNodes = new HashSet<V>();
final PriorityQueue<WE> orderedEdges =
@@ -202,6 +206,8 @@ final class DefaultSpanningTreeAlgorithm
*/
public <OM extends OrderedMonoid<W>> SpanningTree<V, WE, W>
applyingPrimAlgorithm( OM orderedMonoid )
{
+ checkNotNull( orderedMonoid, "The Prim algorithm can't be calulated
with a null monoid" );
+
final ShortestEdges<V, WE, W> shortestEdges = new ShortestEdges<V, WE,
W>( graph, source, orderedMonoid );
final PriorityQueue<V> unsettledNodes = new PriorityQueue<V>(
graph.getOrder(), shortestEdges );