You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice to use Graphhopper to calulate a distance matrix (or Origin / Destination) matrix from a list of nodes.
This is useful for route optimization.
Either by repetitive use of one-to-all shortest path algorithms like Dijkstra's or maybe use an all-to-all shortest path algorithms such as the Floyd-Warshall algorithm.
It would be nice to use Graphhopper to calulate a distance matrix (or Origin / Destination) matrix from a list of nodes.
This is useful for route optimization.
Either by repetitive use of one-to-all shortest path algorithms like Dijkstra's or maybe use an all-to-all shortest path algorithms such as the Floyd-Warshall algorithm.
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/131.
—
Reply to this email directly or view it on GitHub.
so you can use the DijkstraOneToMany-Algorithm (which is already in use for precalculating for contraction hierarchies) to calculate a row.
Floyd-Warshall is an all-to-all-algorithm, so its actually routing from EVERY node of the graph to every other node. besides its complexity (O(N^3)) is higher than n one-to-many dijsktra's (or even N one-to-all dijkstra's)
The optimized code for these matrix calculation can be hundred times faster and even more. After long internal pro and contra discussions we have decided to keep this code closed source. This Matrix add-on is used in our API, see documentation here.
Hi,
I understand that it may be business reasons for not opening up the code
for an optimized NxM calculation.
But since the OSRM-project already provides the same functionality in open
code I don't really see the advantage of keeping it closed source? My fear
is that customers using graphhopper for optimization problems will look
elsewhere instead.
We think that we provide huge value with GraphHopper itself, being fast, well tested, customizable, written in Java, well designed etc. We have no multi million VCs behind GraphHopper and so we have to take care that GraphHopper can go forward even in a year. And we are very confident to reach this goal with different strategies.
Now if someone wants to use other systems for matrix calculations then some of them will do, and some of them will use the hosted Directions API. It is not expensive and offers fast calculations with the possibility of customized vehicles, with and without CH and is always updated to the latest version.
And probably more importantly you can always use the two for-loops, the add-on 'only' makes usage for matrices easier and faster.
BTW: I do NOT close this issue, things can and will change ;)
Update 2017: see this decision regarding the Isochrone API
Hi,
I totally understand. I have to say it is a fantastic product you've
developed and really hope that more people out there realize it.
I try to tell people about it when I have the chance.
We think that we provide huge value with GraphHopper itself, being fast,
well tested, customizable, written in Java, well designed etc. We have no
(multi million) VC behind GraphHopper and so we have to take care that
GraphHopper can go forward even in a year. And we are very confident to
reach this goal with different ideas, and one of them is the Matrix Add-on.
Now if someone wants to use other systems for matrix calculations then
some of them will do, and some of them will buy our Matrix Add-on. It is
not expensive we think, but more importantly it does not block the usage in
that scenarios (as you can use the two for-loops), it 'only' makes usage
easy and even faster.
BTW: I do NOT close this issue ;)
—
Reply to this email directly or view it on GitHub #131 (comment)
.
I need the distance matrix feature for a mean of 100x100 (all-to-all) queries. The matrix will then be further processed by genetic algorithms for a complex delivery planning and routing problem.
Now before I'm going to implement this in my Fork I wanted to investigate into the current situation of this matter here.
Wouldn't it make sense that GraphHopper provides a (non-optimised) default implementation of the Matrix API? (For the sake of a common API...)
Since you already have implemented an optimised version of this and holding it back for a reason, what would happen if I send you a pull-request with matrix functionality? 😄
This leads to an interesting situation for an (semi) open source project - how to deal with contributions which partially cover closed source features which where intended to be paid for?
That being said, I can somehow understand that you want to keep portions back of your code. On the other hand, this will always lead to such problems, especially if your community grows. Thank you for providing GraphHopper Open Source anyway 👍
Wouldn't it make sense that GraphHopper provides a (non-optimised) default
implementation of the Matrix API? (For the sake of a common API...)
That is a good idea, yes.
Since you already have implemented an optimised version of this and holding it back for a reason
We do not 'holding it back' - you can easily buy it :) !
what would happen if I send you a pull-request with matrix functionality? 😄
That is a very good question and for the last >2 years there was no need to answer this ;)
We will of course not reject it and integrate it if our standards like CLA and unit&integration tests are in place. Commercially it could temporarily make sense to reject this, but our aim is to push our open source projects with the help of our business/company and not the other way around (easier said than done!). Furthermore the 'danger' of a fork would then be higher and we really want to avoid this mess for the sake of our community & quality etc.
That being said, I can somehow understand that you want to keep portions back of your code. On the other hand, this will always lead to such problems, especially if your community grows.
We do not see this as a real problem. In fact we will have to think about closed vs. open features from time to time but our business model is not founded on closed source although it makes it a bit easier at the start with some closed source features. BTW: see here for a current comparison.
Thank you for providing GraphHopper Open Source anyway 👍
I will make it extensible so its possible to create your own MatrixAlgorithm provider. In the beginning there will be a simplistic two-for loop implementation and after that the one-to-many Dijkstra.
Depending on the performance of the latter, I will either go with the one-to-many Dijkstra or dive deeper to use a more optimised algorithm which actually can reuse data-structures for the whole matrix calculation.
I would prefer this to be in a separate class like MatrixModule and pass the GraphHopper class in the constructor. As currently the GraphHopper class is really big and needs some separation :)
Or another way would be to have it the way you described and try to separate all the functionality into MatrixAlgorithm or something to reduce the LOC in GraphHopper.java :)
The way I see it GraphHopper acts as a Facade and should give simple access to all parts.
As currently the GraphHopper class is really big and needs some separation
Thats what I just thought as well. There are a lot of things in this class which could be refactored out. Specifically, I'd say it would make sense to separate the construction of a GraphHopper into a GraphHopperFactory. This would remove a lot of boilerplate, all the argument parsing etc. As a side effect, it would also remove the OSM dependencies and make it truly generic.
Also, Storage handling and routing (calcPath) could be moved in separate classes.
GraphHopper would then just compose the separated modules and provide a easy to use API for users as it does now.
So yes, the last thing I'll do is going to bloat GraphHopper class, it will probably get this matrix method just delegate it to a MatrixAlgorithm. All the matrix stuff will land in a separate package anyway.
@karussell I would be happy to pick this up. Given that forks already include this, like RPHAST in openrouteservice, it doesn't make sense not to have a matrix API for graphhopper. If you agree, I would like to implement RPHAST or a minimal matrix API as suggested in this issue. What do you think ?
Over the years we have learned a lot and have decided to not open source the Matrix component for now and also not include a worse and slower or "minimal" Matrix alternative as once suggested.
Just for clarity: GraphHopper's A-to-B routing functionality is and will remain 100% open and we will further invest into it. Including GraphHopper Maps and our support for photon and OpenStreetMap.
Activity
PhilHa commentedon Dec 11, 2013
Do you really intend to calculate an all-to-all shortest path or just a distance matrix from some selected nodes?
matsjg commentedon Dec 11, 2013
Ah, I should have been more explicit.
The latter, send in a list of nodes and get a matrix with distances (all to all) between the selected nodes.
/M
11 dec 2013 kl. 17:21 skrev PhilHa [email protected]:
PhilHa commentedon Dec 11, 2013
so you can use the DijkstraOneToMany-Algorithm (which is already in use for precalculating for contraction hierarchies) to calculate a row.
Floyd-Warshall is an all-to-all-algorithm, so its actually routing from EVERY node of the graph to every other node. besides its complexity (O(N^3)) is higher than n one-to-many dijsktra's (or even N one-to-all dijkstra's)
karussell commentedon Oct 27, 2014
You can always run two for loops like here
The optimized code for these matrix calculation can be hundred times faster and even more. After long internal pro and contra discussions we have decided to keep this code closed source. This Matrix add-on is used in our API, see documentation here.
matsjg commentedon Oct 27, 2014
Hi,
I understand that it may be business reasons for not opening up the code
for an optimized NxM calculation.
But since the OSRM-project already provides the same functionality in open
code I don't really see the advantage of keeping it closed source? My fear
is that customers using graphhopper for optimization problems will look
elsewhere instead.
Best regards,
Mats
On Mon, Oct 27, 2014 at 1:27 PM, Peter [email protected] wrote:
karussell commentedon Oct 27, 2014
Sure, let me explain.
We think that we provide huge value with GraphHopper itself, being fast, well tested, customizable, written in Java, well designed etc. We have no multi million VCs behind GraphHopper and so we have to take care that GraphHopper can go forward even in a year. And we are very confident to reach this goal with different strategies.
Now if someone wants to use other systems for matrix calculations then some of them will do, and some of them will use the hosted Directions API. It is not expensive and offers fast calculations with the possibility of customized vehicles, with and without CH and is always updated to the latest version.
And probably more importantly you can always use the two for-loops, the add-on 'only' makes usage for matrices easier and faster.
BTW: I do NOT close this issue, things can and will change ;)
Update 2017: see this decision regarding the Isochrone API
matsjg commentedon Oct 27, 2014
Hi,
I totally understand. I have to say it is a fantastic product you've
developed and really hope that more people out there realize it.
I try to tell people about it when I have the chance.
Keep up the good work!
/M
On Mon, Oct 27, 2014 at 1:59 PM, Peter [email protected] wrote:
karussell commentedon Oct 27, 2014
Thanks for understanding & spreading the word :) !
IsNull commentedon Apr 21, 2016
I need the distance matrix feature for a mean of 100x100 (all-to-all) queries. The matrix will then be further processed by genetic algorithms for a complex delivery planning and routing problem.
Now before I'm going to implement this in my Fork I wanted to investigate into the current situation of this matter here.
This leads to an interesting situation for an (semi) open source project - how to deal with contributions which partially cover closed source features which where intended to be paid for?
That being said, I can somehow understand that you want to keep portions back of your code. On the other hand, this will always lead to such problems, especially if your community grows. Thank you for providing GraphHopper Open Source anyway 👍
karussell commentedon Apr 21, 2016
That is a good idea, yes.
We do not 'holding it back' - you can easily buy it :) !
That is a very good question and for the last >2 years there was no need to answer this ;)
We will of course not reject it and integrate it if our standards like CLA and unit&integration tests are in place. Commercially it could temporarily make sense to reject this, but our aim is to push our open source projects with the help of our business/company and not the other way around (easier said than done!). Furthermore the 'danger' of a fork would then be higher and we really want to avoid this mess for the sake of our community & quality etc.
We do not see this as a real problem. In fact we will have to think about closed vs. open features from time to time but our business model is not founded on closed source although it makes it a bit easier at the start with some closed source features. BTW: see here for a current comparison.
Thanks for this kind words!
IsNull commentedon Apr 21, 2016
Ok that sounds great.
I give it a try an implement a matrix method in the lines of
I will make it extensible so its possible to create your own MatrixAlgorithm provider. In the beginning there will be a simplistic two-for loop implementation and after that the one-to-many Dijkstra.
Depending on the performance of the latter, I will either go with the one-to-many Dijkstra or dive deeper to use a more optimised algorithm which actually can reuse data-structures for the whole matrix calculation.
karussell commentedon Apr 21, 2016
I would prefer this to be in a separate class like MatrixModule and pass the GraphHopper class in the constructor. As currently the GraphHopper class is really big and needs some separation :)
Or another way would be to have it the way you described and try to separate all the functionality into
MatrixAlgorithmor something to reduce the LOC inGraphHopper.java:)IsNull commentedon Apr 21, 2016
The way I see it GraphHopper acts as a Facade and should give simple access to all parts.
Thats what I just thought as well. There are a lot of things in this class which could be refactored out. Specifically, I'd say it would make sense to separate the construction of a GraphHopper into a GraphHopperFactory. This would remove a lot of boilerplate, all the argument parsing etc. As a side effect, it would also remove the OSM dependencies and make it truly generic.
Also, Storage handling and routing (calcPath) could be moved in separate classes.
GraphHopper would then just compose the separated modules and provide a easy to use API for users as it does now.
So yes, the last thing I'll do is going to bloat GraphHopper class, it will probably get this matrix method just delegate it to a MatrixAlgorithm. All the matrix stuff will land in a separate package anyway.
karussell commentedon Apr 21, 2016
Perfect & I 100% agree!
Yes, this will happen in #450
IsNull commentedon Apr 21, 2016
See Pull-Request (WIP) #705
FeNoMeNa commentedon Jan 6, 2020
Any progress? :)
store layer in URL and pick locale for initial state (graphhopper#131)
mehrdad3301 commentedon Oct 15, 2026
@karussell I would be happy to pick this up. Given that forks already include this, like RPHAST in openrouteservice, it doesn't make sense not to have a matrix API for graphhopper. If you agree, I would like to implement RPHAST or a minimal matrix API as suggested in this issue. What do you think ?
karussell commentedon Oct 19, 2026
Over the years we have learned a lot and have decided to not open source the Matrix component for now and also not include a worse and slower or "minimal" Matrix alternative as once suggested.
Just for clarity: GraphHopper's A-to-B routing functionality is and will remain 100% open and we will further invest into it. Including GraphHopper Maps and our support for photon and OpenStreetMap.
btw: @mehrdad3301 if your employer uses GraphHopper please do us a favour and ask them if we can include them at https://www.graphhopper.com/open-source/