Question

What's the best way to implement weighted graph using Redis?

We will mostly search for shortest paths over the graph (probably using the Dijkstra algorithm)

Currently we considered adding the edges to Redis

For each node, we will have the nodeId as the key and a sortedset of keys of referenced nodes the score of each nodeId in the sortedSet is the weight of the edge.

What do you think? Correct me if I am wrong but the only bummer here is that for each query for the next node in a sortedset we pay O(logn) instead of O(1)...

http://redis.io/commands/zrange

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top