AbsoluteOneCenter { static <V> List<V> distanceOrderedVertices(final Distance<V> distance, final V v, final Comparator<V> comparator) { final Map<V, Number> map = distance.getDistanceMap(v); List<V> list = new ArrayList<V>(map.keySet()); Collections.sort(list, new Comparator<V>() { public int compare(V a, V b) { if (map.get(a).equals(map.get(b))) { return comparator == null ? 0 : comparator.compare(a, b); } else { return ((Double)map.get(b).doubleValue()).compareTo(map.get(a).doubleValue()); } } }); return list; } AbsoluteOneCenter(final UndirectedGraph<V, E> graph);  AbsoluteOneCenter(final UndirectedGraph<V, E> graph, final Comparator<V> comparator);  AbsoluteOneCenter(final UndirectedGraph<V, E> graph, final Transformer<E, Number> edgeLength);  AbsoluteOneCenter(final UndirectedGraph<V, E> graph, final Transformer<E, Number> edgeLength, final Comparator<V> comparator);  AbsoluteOneCenter(final UndirectedGraph<V, E> graph, final Transformer<E, Number> edgeLength, final Distance<V> distance);  AbsoluteOneCenter(final UndirectedGraph<V, E> graph, final Transformer<E, Number> edgeLength, final Distance<V> distance, final Comparator<V> comparator); PointOnEdge<V, E> getCenter();  }
@Test public void testVertexOrder() { final UndirectedGraph<Integer, Integer> g = lineGraph(); final DijkstraDistance<Integer, Integer> distance = new DijkstraDistance<Integer, Integer>(g); assertEquals(Arrays.asList(4, 3, 2, 1, 0), AbsoluteOneCenter.distanceOrderedVertices(distance, 0, intComparator())); assertEquals(Arrays.asList(4, 3, 0, 2, 1), AbsoluteOneCenter.distanceOrderedVertices(distance, 1, intComparator())); assertEquals(Arrays.asList(0, 4, 1, 3, 2), AbsoluteOneCenter.distanceOrderedVertices(distance, 2, intComparator())); }