Skip to content

Using GraphHopper on non-OSM data to calculate centrality measures #5

Closed

Description

@agouge

Hello,

I am currently writing a plugin for the open-source Geographic Information System (GIS) OrbisGIS called GDMS-topology consisting of several graph traversal tools and network analysis measures (e.g., closeness and betweenness centrality) for use on transportation networks. The issue is that these centrality measures require the calculation of all shortest paths in the network, and depending on the network, this calculation can take a very long time.

I have tested the NetworkAnalyzer plugin for Cytoscape on Nantes (Métropole), France using a graph produced from the IGN's BD TOPO route data. The graph has about 180 000 nodes and 235 000 edges, and the calculation has been running for almost a week on a personal computer. To try to cut down on this calculation time, I have become interested in contraction hiearchies. I looked for a Java implementation and I found GraphHopper.

I originally tried using JGraphT-SNA, a Java library based on JGraphT where these centrality measures and many other social network analysis algorithms are implemented. I used JGraphT-SNA to calculate closeness centrality on Nantes, but the calculation was about 7 times slower than NetworkAnalyzer. I'm hoping that a GraphHopper-based (and more specifically, a contraction hierarchies-based) implementation of these centrality measures will be much quicker.

For this reason, I have a few questions:

  1. Though GraphHopper was designed for use with OSM data, I would like to use it on graphs constructed in OrbisGIS. A graph in OrbisGIS consists of a table of nodes and a table of edges listing start nodes and end nodes. Do you think it will be relatively easy to make the connection between an OrbisGIS graph and GraphHopper? I would be possible to supply the tables in .csv format, for example. I'm looking into LevelGraphStorage.
  2. I was also wondering if you could explain the format GraphHopper uses to store the graph. GraphHopper seems to produce three files: edges, loc2idIndex and nodes. I would be particularly interested in the case where we calculate the contraction hierarchies, make some updates to the graph (delete a road, for example), and recalculate the contraction hiearchies. Is it necessary to start over, or can the contraction hierarchies be updated in an efficient manner?
  3. What heuristics are used to establish the node order necessary for calculating the contraction hierarchies?
  4. Which weight is used in determining the shortest path? (Only distance?) Is it possible to use different weights?

Thank you for your time and help!

Activity

  1. karussell commented on Dec 5, 2012

    @karussell
    Member

    The issue is that these centrality measures require the calculation of all shortest paths ...

    ... centrality measures will be much quicker.

    are there really no faster ways? probably the contraction hierarchy itself as we assign more important nodes a higher level ... (?)

    Do you think it will be relatively easy to make the connection between an OrbisGIS graph and GraphHopper?

    yes this should be easy. Either implement Graph (or extend GraphStorage) or fill LevelGraphStorage with your tsv data.

    Is it necessary to start over, or can the contraction hierarchies be updated in an efficient manner?

    in theory it is necessary to start over, but under specific circumstances it is ok to apply minor modifications (but not optimal in terms of speed). I'll search ...

    What heuristics are used to establish the node order necessary for calculating the contraction hierarchies?

    the edge difference, the original edges count and the contracted neighbors:

    https://github.com/graphhopper/graphhopper/blob/master/src/main/java/com/graphhopper/routing/ch/PrepareContractionHierarchies.java#L218

    Which weight is used in determining the shortest path? (Only distance?) Is it possible to use different weights?

    you can use everything for weight. look into the PrepareCH class again where I'm doing:

    iter.distance(prepareWeightCalc.getWeight(iter.distance(), iter.flags()));

    this looks a bit strange but it calculates newDistance = time = distance / velocity. Some further explanations why this is necessary:

    1. the normal dijkstra takes care on demand of the flags (road type) and can calculate the weight from it, so I can say for every algorithm execution if I want the fastest or the shortest (or whatever)!
    2. but the CH enabled dijkstra are a bit inflexible as they cannot do that sort of runtime-weight changing thing. So graphhopper only looks into the distance as weight. We could make the CH more flexible but we would need to introduce a shortcuts for every weight: one for shortest and one for fastest (etc). This would blow up the graph even more.
  2. karussell commented on Dec 5, 2012

    @karussell
    Member

    search for "Dynamic highway-node routing." it is not that easy/quick.

  3. karussell commented on Dec 6, 2012

    @karussell
    Member

    3 notes (or how you could try to avoid CH):

    1. you could just try it again just with graphhopper and its optimized datastructures + algorithms. you could use bidirectional dijkstra, sort the graph, etc
    2. to find out which nodes (or edges) are important my intuition tells me that you could pick start+end at random and do routing. For every node (or edge) you have a counter and you increase that if your random path contains the node. Now iterate until you have enough ... your counter array now tells you which nodes are more important (involved in more routes)
    3. use DijkstraSimple and when you've created the single source shortest-path-tree (SSPT) for one route do not throw it away - reuse it for the next destination point (same start point). So you basically have a one-to-many routing where for you n=200k and every call should be less than 0.05s (not sure how long path extraction for 200k nodes of one SSP tree will take) => ~2h

    Or combine the points somehow (e.g. do some random routing and reuse the SSP tree)

  4. agouge commented on Dec 6, 2012

    @agouge
    Author

    Thanks for all the info!

    I wrote some code to load my csv data (produced by my ST_Graph function) into a LevelGraphStorage. I'll soon redo my ST_ClosenessCentrality function in order to see if GraphHopper can offer some speed improvements by means of contraction hierarchies.

    I'll keep you up to date!

  5. karussell commented on Dec 18, 2012

    @karussell
    Member

    All things clarified here and would you close this? (no problem if you reopen at a later time)

  6. agouge commented on Dec 19, 2012

    @agouge
    Author

    Yes, thanks!

  7. rakeshramesh commented on Feb 7, 2013

    @rakeshramesh

    I need help in executing this file ..I want to find the node ordering for my given input..can u kindly tell me the steps ?/

  8. karussell commented on Feb 7, 2013

    @karussell
    Member

    Please avoid posting your questions more than once - they won't get answered faster with this tactic - see #14 !

  9. rakeshramesh commented on Feb 7, 2013

    @rakeshramesh

    sorry ....I wasn't able to view it earlier as the filter was applied ....

  10. karussell commented on Apr 22, 2013

    @karussell
    Member

    @agouge do you have a comparison of the speed from graphhopper vs. jgrapht-sna? Preferable normal dijkstra + dijkstra-CH :) !

  11. added 2 commits that reference this issue on May 15, 2015
  12. added a commit that references this issue on Jun 23, 2020
  13. added a commit that references this issue on Jul 10, 2020
  14. added a commit that references this issue on Jul 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions