use of com.graphhopper.routing.subnetwork.PrepareRoutingSubnetworks.PrepEdgeFilter in project graphhopper by graphhopper.
the class PrepareRoutingSubnetworksTest method testFindSubnetworks.
@Test
public void testFindSubnetworks() {
GraphHopperStorage g = createSubnetworkTestStorage();
PrepEdgeFilter filter = new PrepEdgeFilter(carFlagEncoder);
PrepareRoutingSubnetworks instance = new PrepareRoutingSubnetworks(g, Collections.singletonList(carFlagEncoder));
List<IntArrayList> components = instance.findSubnetworks(filter);
assertEquals(3, components.size());
// start is at 0 => large network
assertEquals(Helper.createTList(0, 7, 3, 13, 5), components.get(0));
// next smallest and unvisited node is 1 => big network
assertEquals(Helper.createTList(1, 8, 4, 2, 11, 12, 9, 15), components.get(1));
assertEquals(Helper.createTList(6, 14, 10), components.get(2));
}
use of com.graphhopper.routing.subnetwork.PrepareRoutingSubnetworks.PrepEdgeFilter in project graphhopper by graphhopper.
the class PrepareRoutingSubnetworksTest method testRemoveDeadEndUnvisitedNetworks.
@Test
public void testRemoveDeadEndUnvisitedNetworks() {
GraphHopperStorage g = createDeadEndUnvisitedNetworkStorage(em);
assertEquals(11, g.getNodes());
PrepareRoutingSubnetworks instance = new PrepareRoutingSubnetworks(g, Collections.singletonList(carFlagEncoder)).setMinOneWayNetworkSize(3);
int removed = instance.removeDeadEndUnvisitedNetworks(new PrepEdgeFilter(carFlagEncoder));
assertEquals(3, removed);
instance.markNodesRemovedIfUnreachable();
g.optimize();
assertEquals(8, g.getNodes());
}
use of com.graphhopper.routing.subnetwork.PrepareRoutingSubnetworks.PrepEdgeFilter in project graphhopper by graphhopper.
the class PrepareRoutingSubnetworksTest method test481.
@Test
public void test481() {
// 0->1->3->4->5->6
// 2 7<--/
GraphHopperStorage g = createStorage(em);
g.edge(0, 1, 1, false);
g.edge(1, 2, 1, false);
g.edge(2, 0, 1, false);
g.edge(1, 3, 1, false);
g.edge(3, 4, 1, false);
g.edge(4, 5, 1, false);
g.edge(5, 6, 1, false);
g.edge(6, 7, 1, false);
g.edge(7, 4, 1, false);
PrepareRoutingSubnetworks instance = new PrepareRoutingSubnetworks(g, Collections.singletonList(carFlagEncoder)).setMinOneWayNetworkSize(2).setMinNetworkSize(4);
instance.doWork();
// only one remaining network
List<IntArrayList> components = instance.findSubnetworks(new PrepEdgeFilter(carFlagEncoder));
assertEquals(1, components.size());
}
use of com.graphhopper.routing.subnetwork.PrepareRoutingSubnetworks.PrepEdgeFilter in project graphhopper by graphhopper.
the class PrepareRoutingSubnetworksTest method testKeepLargestNetworks.
@Test
public void testKeepLargestNetworks() {
GraphHopperStorage g = createSubnetworkTestStorage();
PrepEdgeFilter filter = new PrepEdgeFilter(carFlagEncoder);
PrepareRoutingSubnetworks instance = new PrepareRoutingSubnetworks(g, Collections.singletonList(carFlagEncoder));
List<IntArrayList> components = instance.findSubnetworks(filter);
assertEquals(3, components.size());
int removedEdges = instance.keepLargeNetworks(filter, components);
assertEquals(8, removedEdges);
instance.markNodesRemovedIfUnreachable();
g.optimize();
assertEquals(8, g.getNodes());
assertEquals(Arrays.<String>asList(), GHUtility.getProblems(g));
components = instance.findSubnetworks(filter);
assertEquals(1, components.size());
}
use of com.graphhopper.routing.subnetwork.PrepareRoutingSubnetworks.PrepEdgeFilter in project graphhopper by graphhopper.
the class PrepareRoutingSubnetworksTest method testNodeOrderingRegression.
// Previous two-pass implementation failed on 1 -> 2 -> 0
@Test
public void testNodeOrderingRegression() {
// 1 -> 2 -> 0
GraphHopperStorage g = createStorage(em);
g.edge(1, 2, 1, false);
g.edge(2, 0, 1, false);
PrepareRoutingSubnetworks instance = new PrepareRoutingSubnetworks(g, Collections.singletonList(carFlagEncoder)).setMinOneWayNetworkSize(2);
int removedEdges = instance.removeDeadEndUnvisitedNetworks(new PrepEdgeFilter(carFlagEncoder));
assertEquals(2, removedEdges);
}
Aggregations