### Question:
GHUtility { public static Graph copyTo(Graph fromGraph, Graph toGraph) { if (fromGraph.getTurnCostStorage() != null) { throw new IllegalArgumentException("Copying a graph is currently not supported in the presence of turn costs"); } AllEdgesIterator eIter = fromGraph.getAllEdges(); while (eIter.next()) { int base = eIter.getBaseNode(); int adj = eIter.getAdjNode(); toGraph.edge(base, adj).copyPropertiesFrom(eIter); } NodeAccess fna = fromGraph.getNodeAccess(); NodeAccess tna = toGraph.getNodeAccess(); int nodes = fromGraph.getNodes(); for (int node = 0; node < nodes; node++) { if (tna.is3D()) tna.setNode(node, fna.getLatitude(node), fna.getLongitude(node), fna.getElevation(node)); else tna.setNode(node, fna.getLatitude(node), fna.getLongitude(node)); } return toGraph; }  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 printGraphForUnitTest(Graph g, FlagEncoder encoder); static void printGraphForUnitTest(Graph g, FlagEncoder encoder, BBox bBox); static void buildRandomGraph(Graph graph, Random random, int numNodes, double meanDegree, boolean allowLoops,
                                        boolean allowZeroDistance, DecimalEncodedValue randomSpeedEnc,
                                        double pNonZeroLoop, double pBothDir, double pRandomOffset); static double getDistance(int from, int to, NodeAccess nodeAccess); static void addRandomTurnCosts(Graph graph, long seed, EncodingManager em, FlagEncoder encoder, int maxTurnCost, TurnCostStorage turnCostStorage); 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 IntsRef flags); static EdgeIteratorState createMockedEdgeIteratorState(final double distance, final IntsRef flags,
                                                                  final int base, final int adj, final int edge, final int origFirst, final int origLast); 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); static IntsRef setProperties(IntsRef edgeFlags, FlagEncoder encoder, double averageSpeed, boolean fwd, boolean bwd); static EdgeIteratorState setProperties(EdgeIteratorState edge, FlagEncoder encoder, double fwdSpeed, double bwdSpeed); static IntsRef setProperties(IntsRef edgeFlags, FlagEncoder encoder, double fwdSpeed, double bwdSpeed); static EdgeIteratorState setProperties(EdgeIteratorState edge, FlagEncoder encoder, double averageSpeed, boolean fwd, boolean bwd); static void updateDistancesFor(Graph g, int node, double lat, double lon); static double calcWeightWithTurnWeight(Weighting weighting, EdgeIteratorState edgeState, boolean reverse, int prevOrNextEdgeId); static long calcMillisWithTurnMillis(Weighting weighting, EdgeIteratorState edgeState, boolean reverse, int prevOrNextEdgeId);  }### Answer:
@Test public void testCopyWithSelfRef() { Graph g = initUnsorted(createGraph()); g.edge(0, 0, 11, true); Graph g2 = new GraphBuilder(encodingManager).create(); GHUtility.copyTo(g, g2); assertEquals(g.getEdges(), g2.getEdges()); }