Using a GDS path finding algorithm with dynamic relationship weights


I've built a graph of the London underground map. My application uses the graph to find the shortest path to all other nodes from the source node that is passed into the query, for this I'm using the Dijkstra Single-Source algorithm available through the Graph Data Science plugin.

It works well and completes the task I'm using it for, but the paths are often not very optimal when applied to real life. For example it might suggest changing lines every 1 or 2 stops to reduce the cost by 1 or 2 minutes in total, but in reality those line changes would take several minutes each themselves.

Each relationship currently has a line property, I could reload the data so that the line is the relationship type if that would help, but currently the algorithm is completely agnostic to this property. I need to make it so that when the algorithm is choosing its next node or choosing between multiple paths to the same node, the cost of using that path is dynamically increased if the line property of that path is different to the line property of the previous step on the path.

Is this possible at all?

Thanks for any help,


Relationship weights are static, I don't think there's a way to dynamically compute the cost. That is a cool feature though so perhaps you can add it as a suggestion on the Graph Data Science repository. You could also include a suggestion for what the syntax should look like.

Cheers, Mark