### Question:
GHUtility { public static Graph sortDFS(Graph g, Graph sortedGraph) { int nodes = g.getNodes(); final GHIntArrayList list = new GHIntArrayList(nodes); list.fill(nodes, -1); final GHBitSetImpl bitset = new GHBitSetImpl(nodes); final AtomicInteger ref = new AtomicInteger(-1); EdgeExplorer explorer = g.createEdgeExplorer(); for (int startNode = 0; startNode >= 0 && startNode < nodes; startNode = bitset.nextClear(startNode + 1)) { new DepthFirstSearch() { @Override protected GHBitSet createBitSet() { return bitset; } @Override protected boolean goFurther(int nodeId) { list.set(nodeId, ref.incrementAndGet()); return super.goFurther(nodeId); } }.start(explorer, startNode); } return createSortedGraph(g, sortedGraph, list); }  static List<String> getProblems(Graph g); static int count(EdgeIterator iter); static Set<Integer> asSet(int... values); static Set<Integer> getNeighbors(EdgeIterator iter); static List<Integer> getEdgeIds(EdgeIterator iter); static void printEdgeInfo(final Graph g, FlagEncoder encoder); static void printInfo(final Graph g, int startNode, final int counts, final EdgeFilter filter); static String getNodeInfo(CHGraph g, int nodeId, EdgeFilter filter); static String getNodeInfo(Graph g, int nodeId, EdgeFilter filter); static Graph shuffle(Graph g, Graph sortedGraph); static Graph sortDFS(Graph g, Graph sortedGraph); static Graph copyTo(Graph fromGraph, Graph toGraph); static GraphHopperStorage newStorage(GraphHopperStorage store); static int getAdjNode(Graph g, int edge, int adjNode); static EdgeIteratorState createMockedEdgeIteratorState(final double distance, final long flags); static EdgeIteratorState getEdge(Graph graph, int base, int adj); static int createEdgeKey(int nodeA, int nodeB, int edgeId, boolean reverse); static boolean isSameEdgeKeys(int edgeKey1, int edgeKey2); static int reverseEdgeKey(int edgeKey); static int getEdgeFromEdgeKey(int edgeKey);  }### Answer:
@Test public void testSort() { Graph g = initUnsorted(createGraph()); Graph newG = GHUtility.sortDFS(g, createGraph()); assertEquals(g.getNodes(), newG.getNodes()); NodeAccess na = newG.getNodeAccess(); assertEquals(0, na.getLatitude(0), 1e-4); assertEquals(2.5, na.getLatitude(1), 1e-4); assertEquals(4.5, na.getLatitude(2), 1e-4); assertEquals(4.6, na.getLatitude(3), 1e-4); assertEquals(3.0, na.getLatitude(4), 1e-4); assertEquals(5.0, na.getLatitude(5), 1e-4); assertEquals(4.2, na.getLatitude(6), 1e-4); }
@Test public void testSort2() { Graph g = initUnsorted(createGraph()); Graph newG = GHUtility.sortDFS(g, createGraph()); assertEquals(g.getNodes(), newG.getNodes()); NodeAccess na = newG.getNodeAccess(); assertEquals(0, na.getLatitude(0), 1e-4); assertEquals(2.5, na.getLatitude(1), 1e-4); assertEquals(4.5, na.getLatitude(2), 1e-4); assertEquals(4.6, na.getLatitude(3), 1e-4); }
@Test public void testSortDirected() { Graph g = createGraph(); NodeAccess na = g.getNodeAccess(); na.setNode(0, 0, 1); na.setNode(1, 2.5, 2); na.setNode(2, 3.5, 3); g.edge(0, 1, 1.1, false); g.edge(2, 1, 1.1, false); GHUtility.sortDFS(g, createGraph()); }