use of com.graphhopper.routing.subnetwork.EdgeBasedTarjanSCC.ConnectedComponents in project graphhopper by graphhopper.
the class EdgeBasedTarjanSCCTest method linearOneWay.
@Test
public void linearOneWay() {
GraphHopperStorage g = new GraphBuilder(em).create();
// 0 -> 1 -> 2
GHUtility.setSpeed(60, true, false, encoder, g.edge(0, 1).setDistance(1));
GHUtility.setSpeed(60, true, false, encoder, g.edge(1, 2).setDistance(1));
ConnectedComponents result = EdgeBasedTarjanSCC.findComponentsRecursive(g, fwdAccessFilter, false);
assertEquals(4, result.getEdgeKeys());
assertEquals(4, result.getTotalComponents());
assertEquals(0, result.getComponents().size());
// we only have two directed edges here, but we always calculate the component indices for all edge keys and
// here every (directed) edge belongs to its own component
assertEquals(4, result.getSingleEdgeComponents().cardinality());
assertEquals(IntArrayList.from(), result.getBiggestComponent());
}
use of com.graphhopper.routing.subnetwork.EdgeBasedTarjanSCC.ConnectedComponents in project graphhopper by graphhopper.
the class EdgeBasedTarjanSCCTest method doImplicitVsExplicit.
private void doImplicitVsExplicit(boolean excludeSingle) {
GraphHopperStorage g = new GraphBuilder(em).create();
long seed = System.nanoTime();
Random rnd = new Random(seed);
GHUtility.buildRandomGraph(g, rnd, 500, 2, true, true, encoder.getAccessEnc(), encoder.getAverageSpeedEnc(), 60d, 0.8, 0.7, 0);
ConnectedComponents implicit = EdgeBasedTarjanSCC.findComponentsRecursive(g, fwdAccessFilter, excludeSingle);
ConnectedComponents explicit = EdgeBasedTarjanSCC.findComponents(g, fwdAccessFilter, excludeSingle);
assertEquals(2 * g.getEdges(), implicit.getEdgeKeys(), "total number of edge keys in connected components should equal twice the number of edges in graph");
assertEquals(2 * g.getEdges(), explicit.getEdgeKeys(), "total number of edge keys in connected components should equal twice the number of edges in graph");
compareResults(g, seed, implicit, explicit);
}
Aggregations