Permalink
Browse files

subList bugfix

  • Loading branch information...
jcccf committed Jun 28, 2012
1 parent cbeaf53 commit ae9727eb736c23239fba72102b4c61768c86f8e1
Showing with 3 additions and 1 deletion.
  1. +3 −1 examples/java/RandomWalk.java
@@ -66,7 +66,9 @@ public static void main(String[] args) {
// Sort neighbors (or nodes) in descending number of visits and take the top 10 neighbors
List<Integer> topNeighbors = Ordering.natural().onResultOf(Functions.forMap(neighbors)).reverse()
- .immutableSortedCopy(neighbors.keySet()).subList(0, 10);
+ .immutableSortedCopy(neighbors.keySet());
+
+ if (topNeighbors.size() > 10) topNeighbors = topNeighbors.subList(0, 10);
// Print the top 10 neighbors (and paths)
System.out.printf("%8s%10s\t%s\n", "NodeID", "#Visits", "Top 2 Paths with counts");

0 comments on commit ae9727e

Please sign in to comment.