### Question:
QueryGraph implements Graph { void fillVirtualEdges(IntObjectMap<VirtualEdgeIterator> node2Edge, int towerNode, EdgeExplorer mainExpl) { if (isVirtualNode(towerNode)) throw new IllegalStateException("Node should not be virtual:" + towerNode + ", " + node2Edge); VirtualEdgeIterator vIter = node2Edge.get(towerNode); IntArrayList ignoreEdges = new IntArrayList(vIter.count() * 2); while (vIter.next()) { EdgeIteratorState edge = queryResults.get(vIter.getAdjNode() - mainNodes).getClosestEdge(); ignoreEdges.add(edge.getEdge()); } vIter.reset(); EdgeIterator iter = mainExpl.setBaseNode(towerNode); while (iter.next()) { if (!ignoreEdges.contains(iter.getEdge())) vIter.add(iter.detach(false)); } } QueryGraph(Graph graph); private  QueryGraph(Graph graph, QueryGraph superQueryGraph); QueryGraph lookup(QueryResult fromRes, QueryResult toRes); void lookup(List<QueryResult> resList); @Override Graph getBaseGraph(); EdgeIteratorState getOriginalEdgeFromVirtNode(int nodeId); boolean isVirtualEdge(int edgeId); boolean isVirtualNode(int nodeId); QueryGraph setUseEdgeExplorerCache(boolean useEECache); boolean enforceHeading(int nodeId, double favoredHeading, boolean incoming); void unfavorVirtualEdgePair(int virtualNodeId, int virtualEdgeId); Set<EdgeIteratorState> getUnfavoredVirtualEdges(); void clearUnfavoredStatus(); @Override int getNodes(); @Override NodeAccess getNodeAccess(); @Override BBox getBounds(); @Override EdgeIteratorState getEdgeIteratorState(int origEdgeId, int adjNode); @Override EdgeExplorer createEdgeExplorer(final EdgeFilter edgeFilter); @Override /** * @see QueryGraph */ EdgeExplorer createEdgeExplorer(); @Override AllEdgesIterator getAllEdges(); @Override EdgeIteratorState edge(int a, int b); EdgeIteratorState edge(int a, int b, double distance, int flags); @Override EdgeIteratorState edge(int a, int b, double distance, boolean bothDirections); @Override Graph copyTo(Graph g); @Override GraphExtension getExtension();  }### Answer:
@Test public void testFillVirtualEdges() { initGraph(g); g.getNodeAccess().setNode(3, 0, 1); g.edge(1, 3); final int baseNode = 1; EdgeIterator iter = g.createEdgeExplorer().setBaseNode(baseNode); iter.next(); QueryResult res1 = createLocationResult(2, 1.7, iter, 1, PILLAR); QueryGraph queryGraph = new QueryGraph(g) { @Override void fillVirtualEdges(IntObjectMap<VirtualEdgeIterator> node2Edge, int towerNode, EdgeExplorer mainExpl) { super.fillVirtualEdges(node2Edge, towerNode, mainExpl); if (towerNode == 3) assertEquals("[3->4]", node2Edge.get(towerNode).toString()); else if (towerNode == 1) assertEquals("[1->4, 1 1-0]", node2Edge.get(towerNode).toString()); else throw new IllegalStateException("not allowed " + towerNode); } }; queryGraph.lookup(Arrays.asList(res1)); EdgeIteratorState state = GHUtility.getEdge(queryGraph, 0, 1); assertEquals(4, state.fetchWayGeometry(3).size()); state = GHUtility.getEdge(queryGraph, 4, 3); assertEquals(2, state.fetchWayGeometry(3).size()); }