Class PrepareRoutingSubnetworks

java.lang.Object
com.graphhopper.routing.subnetwork.PrepareRoutingSubnetworks

public class PrepareRoutingSubnetworks extends Object
Detects and marks 'subnetworks' with a dedicated subnetwork encoded value. Subnetworks are parts of the road network that are not connected to the rest of the network and that are below a certain size. These can be isolated nodes with no edges at all, but also small subnetworks which could be bugs in OSM data or 'islands' that are separated from the rest of the network because of some missing link, barrier or some closed road for example.

Sometimes there are also subnetworks that can be reached from the main network but not the other way around (or the opposite). For example this can be parking lots that can only be accessed by a single one-way road (a mapping error). These are called 'one-way subnetworks' and are marked using the same subnetwork encoded value, see #86. To find such one-way subnetworks it is important to search for strongly connected components on the directed graph and not do a simple connectivity check for one direction.

Note that it depends on the weighting whether or not edges belong to a subnetwork or not. For example if a weighting 'closes' a bridge to an island the island might become a subnetwork, but if the bridge was open it would belong to the main network. There can even be subnetworks that are due to turn restrictions.

We always run an edge-based connected component search, because this way we retrieve the edges (not the nodes) that belong to each component and can include turn restrictions as well. Node-based component search is faster, but since the subnetwork search goes relatively fast anyway using it has no real benefit.

Author:
Peter Karich, easbar
  • Constructor Details

  • Method Details

    • setMinNetworkSize

      public PrepareRoutingSubnetworks setMinNetworkSize(int minNetworkSize)
      All components of the graph with less than 2*minNetworkSize directed edges (edge keys) will be marked as subnetworks. The biggest component will never be marked as subnetwork, even when it is below this size.
    • setThreads

      public PrepareRoutingSubnetworks setThreads(int threads)
    • doWork

      public int doWork()
      Finds and marks all subnetworks according to setMinNetworkSize(int)
      Returns:
      the total number of marked edges