@Override public int getEdges() { return getAllEdges().length(); }
@Override public int getEdges() { return getAllEdges().length(); }
@Override public int getEdges() { return getAllEdges().length(); }
@Override public int getEdges() { return getAllEdges().length(); }
@Override public int length() { return IntStream.concat( IntStream.of(baseGraph.getAllEdges().length() - 1), extraEdges.stream().mapToInt(VirtualEdgeIteratorState::getEdge)) .max().getAsInt()+1; }
public static void printEdgeInfo(final Graph g, FlagEncoder encoder) { System.out.println("-- Graph nodes:" + g.getNodes() + " edges:" + g.getAllEdges().length() + " ---"); AllEdgesIterator iter = g.getAllEdges(); while (iter.next()) { String prefix = (iter instanceof AllCHEdgesIterator && ((AllCHEdgesIterator) iter).isShortcut()) ? "sc" : " "; String fwdStr = iter.isForward(encoder) ? "fwd" : " "; String bwdStr = iter.isBackward(encoder) ? "bwd" : " "; System.out.println(prefix + " " + iter + " " + fwdStr + " " + bwdStr + " " + iter.getDistance()); } }
private GHBitSet printGraphDetails(GraphHopperStorage g, String vehicleStr) { // graph size (edge, node and storage size) put("graph.nodes", g.getNodes()); put("graph.edges", g.getAllEdges().length()); put("graph.size_in_MB", g.getCapacity() / MB); put("graph.encoder", vehicleStr); AllEdgesIterator iter = g.getAllEdges(); final int maxEdgesId = g.getAllEdges().length(); final GHBitSet allowedEdges = new GHBitSetImpl(maxEdgesId); fillAllowedEdges(iter, allowedEdges); put("graph.valid_edges", allowedEdges.getCardinality()); return allowedEdges; }
final LinkedList<VirtualEdgeIteratorState> additionalEdges = new LinkedList<>(); final Graph overlayGraph = new Graph() { int firstEdge = graphHopperStorage.getAllEdges().length(); final NodeAccess nodeAccess = new NodeAccess() { IntIntHashMap additionalNodeFields = new IntIntHashMap();
private void interpolateElevationsOfTowerNodes() { final AllEdgesIterator edge = storage.getAllEdges(); final GHBitSet visitedEdgeIds = new GHBitSetImpl(edge.length()); final EdgeExplorer edgeExplorer = storage.createEdgeExplorer(); while (edge.next()) { final int edgeId = edge.getEdge(); if (isInterpolatableEdge(edge)) { if (!visitedEdgeIds.contains(edgeId)) { interpolateEdge(edge, visitedEdgeIds, edgeExplorer); } } visitedEdgeIds.add(edgeId); } }
public QueryGraph(Graph graph) { mainGraph = graph; mainNodeAccess = graph.getNodeAccess(); mainNodes = graph.getNodes(); mainEdges = graph.getAllEdges().length(); if (mainGraph.getExtension() instanceof TurnCostExtension) wrappedExtension = new QueryGraphTurnExt(); else wrappedExtension = mainGraph.getExtension(); // create very lightweight QueryGraph which uses variables from this QueryGraph (same virtual edges) baseGraph = new QueryGraph(graph.getBaseGraph(), this) { // override method to avoid stackoverflow @Override public QueryGraph setUseEdgeExplorerCache(boolean useEECache) { baseGraph.useEdgeExplorerCache = useEECache; return baseGraph; } }; }
/** * Internal method to clean up the graph. */ protected void cleanUp() { int prevNodeCount = ghStorage.getNodes(); PrepareRoutingSubnetworks preparation = new PrepareRoutingSubnetworks(ghStorage, encodingManager.fetchEdgeEncoders()); preparation.setMinNetworkSize(minNetworkSize); preparation.setMinOneWayNetworkSize(minOneWayNetworkSize); preparation.doWork(); int currNodeCount = ghStorage.getNodes(); logger.info("edges: " + Helper.nf(ghStorage.getAllEdges().length()) + ", nodes " + Helper.nf(currNodeCount) + ", there were " + Helper.nf(preparation.getMaxSubnetworks()) + " subnetworks. removed them => " + Helper.nf(prevNodeCount - currNodeCount) + " less nodes"); }
@Override protected void prepareCH() { StopWatch sw = new StopWatch().start(); super.prepareCH(); put(Parameters.CH.PREPARE + "time", sw.stop().getMillis()); int edges = getGraphHopperStorage().getAllEdges().length(); if (getCHFactoryDecorator().hasWeightings()) { Weighting weighting = getCHFactoryDecorator().getWeightings().get(0); int edgesAndShortcuts = getGraphHopperStorage().getGraph(CHGraph.class, weighting).getEdges(); put(Parameters.CH.PREPARE + "shortcuts", edgesAndShortcuts - edges); } }
@Test public void testIdentical() { GraphHopperStorage store = new GraphHopperStorage(new RAMDirectory(), encodingManager, true, new GraphExtension.NoOpExtension()); assertEquals(store.getNodes(), store.getGraph(Graph.class).getNodes()); assertEquals(store.getAllEdges().length(), store.getGraph(Graph.class).getAllEdges().length()); }
@Test public void testCopyWithSelfRef() { Graph g = initUnsorted(createGraph()); g.edge(0, 0, 11, true); CHGraph lg = new GraphBuilder(encodingManager).chGraphCreate(new FastestWeighting(carEncoder)); GHUtility.copyTo(g, lg); assertEquals(g.getAllEdges().length(), lg.getEdges()); }
@Test public void testMoreComplexGraph() { GraphHopperStorage g = createGHStorage(); CHGraph lg = g.getGraph(CHGraph.class); initShortcutsGraph(lg); int oldCount = g.getAllEdges().length(); PrepareContractionHierarchies prepare = createPrepareContractionHierarchies(g, lg); prepare.doWork(); assertEquals(oldCount, g.getEdges()); assertEquals(oldCount + 7, lg.getEdges()); }
print("unit_tests" + description + ".all_edge_state_next", miniPerf); final int maxEdgesId = graph.getAllEdges().length(); miniPerf = new MiniPerfTest() { @Override
@Test public void testRoundaboutUnpacking() { GraphHopperStorage g = createGHStorage(); CHGraph lg = g.getGraph(CHGraph.class); initRoundaboutGraph(g); int oldCount = g.getAllEdges().length(); PrepareContractionHierarchies prepare = createPrepareContractionHierarchies(g, lg); prepare.doWork(); assertEquals(oldCount, g.getEdges()); assertEquals(oldCount + 23, lg.getEdges()); RoutingAlgorithm algo = prepare.createAlgo(lg, new AlgorithmOptions(DIJKSTRA_BI, weighting, tMode)); Path p = algo.calcPath(4, 7); assertEquals(IntArrayList.from(4, 5, 6, 7), p.calcNodes()); }
@Test public void testDirectedGraph2() { GraphHopperStorage g = createGHStorage(); CHGraph lg = g.getGraph(CHGraph.class); initDirected2(g); int oldCount = GHUtility.count(g.getAllEdges()); assertEquals(19, oldCount); PrepareContractionHierarchies prepare = createPrepareContractionHierarchies(g, lg); prepare.doWork(); // PrepareTowerNodesShortcutsTest.printEdges(g); assertEquals(oldCount, g.getAllEdges().length()); assertEquals(oldCount, GHUtility.count(g.getAllEdges())); long numShortcuts = 9; assertEquals(numShortcuts, prepare.getShortcuts()); assertEquals(oldCount + numShortcuts, lg.getEdges()); assertEquals(oldCount + numShortcuts, GHUtility.count(lg.getAllEdges())); RoutingAlgorithm algo = prepare.createAlgo(lg, new AlgorithmOptions(DIJKSTRA_BI, weighting, tMode)); Path p = algo.calcPath(0, 10); assertEquals(10, p.getDistance(), 1e-6); assertEquals(IntArrayList.from(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10), p.calcNodes()); }