Author: simonetripodi
Date: Tue Mar 27 20:31:25 2012
New Revision: 1306006

URL: http://svn.apache.org/viewvc?rev=1306006&view=rev
Log:
linked the ELO algorithm executor

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

Modified: 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/CommonsGraph.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/CommonsGraph.java?rev=1306006&r1=1306005&r2=1306006&view=diff
==============================================================================
--- 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/CommonsGraph.java
 (original)
+++ 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/CommonsGraph.java
 Tue Mar 27 20:31:25 2012
@@ -35,6 +35,9 @@ import org.apache.commons.graph.coloring
 import org.apache.commons.graph.coloring.DefaultColorsBuilder;
 import org.apache.commons.graph.connectivity.ConnectivityBuilder;
 import org.apache.commons.graph.connectivity.DefaultConnectivityBuilder;
+import org.apache.commons.graph.elo.DefaultRankingSelector;
+import org.apache.commons.graph.elo.GameResult;
+import org.apache.commons.graph.elo.RankingSelector;
 import org.apache.commons.graph.export.DefaultExportSelector;
 import org.apache.commons.graph.export.NamedExportSelector;
 import org.apache.commons.graph.flow.DefaultFlowWeightedEdgesBuilder;
@@ -156,6 +159,20 @@ public final class CommonsGraph<V, E, G 
     }
 
     /**
+     * Ranks the players (vertices) that took part in a tournament (graph) 
depending on the game results (edges),
+     * applying the <a 
href="http://en.wikipedia.org/wiki/Elo_rating_system.";>Elo Rating System</a>.
+     *
+     * @param <P> the players involved in the tournament
+     * @param tournamentGraph the graph representing the tournament
+     * @return the builder for the functor which returns/update the players 
ranking
+     */
+    public static <P, TG extends DirectedGraph<P, GameResult>> 
RankingSelector<P> eloRate( TG tournamentGraph )
+    {
+        tournamentGraph = checkNotNull( tournamentGraph, "ELO ranking can not 
be applied on null graph!" );
+        return new DefaultRankingSelector<P>( tournamentGraph );
+    }
+
+    /**
      * Creates a new {@link DirectedMutableGraph} instance where vertices
      * are connected as described in the input {@link GraphConnection} 
instance.
      *


Reply via email to