Search in sources :

Example 26 with IntArrayList

use of com.carrotsearch.hppc.IntArrayList 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());
}
Also used : IntArrayList(com.carrotsearch.hppc.IntArrayList) PrepEdgeFilter(com.graphhopper.routing.subnetwork.PrepareRoutingSubnetworks.PrepEdgeFilter) GraphHopperStorage(com.graphhopper.storage.GraphHopperStorage) Test(org.junit.Test)

Example 27 with IntArrayList

use of com.carrotsearch.hppc.IntArrayList in project graphhopper by graphhopper.

the class PrepareRoutingSubnetworksTest method testTarjan.

@Test
public void testTarjan() {
    GraphHopperStorage g = createSubnetworkTestStorage();
    // Requires a single vehicle type, otherwise we throw.
    final EdgeFilter filter = new DefaultEdgeFilter(carFlagEncoder, false, true);
    TarjansSCCAlgorithm tarjan = new TarjansSCCAlgorithm(g, filter, false);
    List<IntArrayList> components = tarjan.findComponents();
    assertEquals(4, components.size());
    assertEquals(IntArrayList.from(13, 5, 3, 7, 0), components.get(0));
    assertEquals(IntArrayList.from(2, 4, 12, 11, 8, 1), components.get(1));
    assertEquals(IntArrayList.from(10, 14, 6), components.get(2));
    assertEquals(IntArrayList.from(15, 9), components.get(3));
}
Also used : PrepEdgeFilter(com.graphhopper.routing.subnetwork.PrepareRoutingSubnetworks.PrepEdgeFilter) IntArrayList(com.carrotsearch.hppc.IntArrayList) GraphHopperStorage(com.graphhopper.storage.GraphHopperStorage) Test(org.junit.Test)

Aggregations

IntArrayList (com.carrotsearch.hppc.IntArrayList)27 GHIntArrayList (com.graphhopper.coll.GHIntArrayList)6 PrepEdgeFilter (com.graphhopper.routing.subnetwork.PrepareRoutingSubnetworks.PrepEdgeFilter)4 FlagEncoder (com.graphhopper.routing.util.FlagEncoder)4 GraphHopperStorage (com.graphhopper.storage.GraphHopperStorage)4 Test (org.junit.Test)4 ScoreDoc (org.apache.lucene.search.ScoreDoc)3 BBox (com.graphhopper.util.shapes.BBox)2 GHPoint (com.graphhopper.util.shapes.GHPoint)2 IOException (java.io.IOException)2 UUID (java.util.UUID)2 FetchSearchResult (org.elasticsearch.search.fetch.FetchSearchResult)2 ShardFetchRequest (org.elasticsearch.search.fetch.ShardFetchRequest)2 QuerySearchResult (org.elasticsearch.search.query.QuerySearchResult)2 QuerySearchResultProvider (org.elasticsearch.search.query.QuerySearchResultProvider)2 IntHashSet (com.carrotsearch.hppc.IntHashSet)1 IntIndexedContainer (com.carrotsearch.hppc.IntIndexedContainer)1 IntObjectHashMap (com.carrotsearch.hppc.IntObjectHashMap)1 GHBitSet (com.graphhopper.coll.GHBitSet)1 GHBitSetImpl (com.graphhopper.coll.GHBitSetImpl)1