You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@giraph.apache.org by Venkata Sastry Malladi <mv...@gmail.com> on 2012/09/24 20:24:24 UTC
All pairs shortest paths
I'm thinking of modifying the simple shortest paths algorithm so that it
calculates the shortest paths between all pairs of nodes (not just from a
single source node). I wanted to get some general advice on whether these
are feasible in Giraph:
1. Without quitting the job after all vertices voteToHalt(), is it possible
to just restart from superstep 0, but with a different source node? In
other words, when we want to do simultaneous runs of the simple shortest
paths algorithm, how can we avoid the overhead of re-reading the graph into
memory between the runs?
2. Is it possible to run some kind of reducer before the vertices are
written to the output? Let's say the VertexWriter outputs something like
(Source, Destination) -> Route for each node. Is it possible to combine
many such outputs to produce a single output? Like (Source, Destination) -
> (Route1, Route2, Route3).
Thanks,
Venkat.
Re: All pairs shortest paths
Posted by André Kelpe <ef...@googlemail.com>.
Hi Venkata!
2012/9/25 Venkata Sastry Malladi <mv...@gmail.com>:
> Thanks for the reply, Sebastian.
>
> The problem I'm working on is a routing algorithm for a country wide railway
> network. I was thinking about two ways to approach it.
How many vertices and edges do you have? Seems of reasonable size...
> 1. Pre calculate the routes. I understand that this is quadratic, but I was
> thinking of using some optimizations to limit the calculations. Like
> restrict the number of hops from the source node, only calculate the route
> to the nearest hub and not every other node, etc.
If this is really just the railroad network, that should be fine. I
have done something similar at my previous job with the road network
on country basis and it took only a few minutes to actually run the
thing on a small-ish cluster. Those networks are usually not billions
of vertices, so no problem as n^2 is still pretty small.
The giraph job we made, was part of a bigger pipeline of jobs (we used
crunch for that btw). The first job would cut out the bare minimum of
data (the graph minus any other attribution), which was the input for
giraph. Then a giraph job read that input created an output file,
which was used as an index by the final algorithm. (We actually
calculated all the routes from all the vertices twice (in both
directions) and filtered in the output writer and that was still fast
enough for us.)
You can do something similar, where you basically use giraph to
calculate your graph index and then stick that into some database
(hbase, redis, mysql whatever works for your dataset) and query that
from your program.
> 2. Use Giraph as a real time query engine - The graph is loaded into the
> memory of a cluster of nodes, and given the source and destination nodes of
> a query, a single source shortest path algorithm is run.
It is not made for real-time queries. As I said, just use giraph to
make your index and keep that in memory with the db of your choice.
HTH
--Andre
Re: All pairs shortest paths
Posted by Venkata Sastry Malladi <mv...@gmail.com>.
Thanks for the reply, Sebastian.
The problem I'm working on is a routing algorithm for a country wide
railway network. I was thinking about two ways to approach it.
1. Pre calculate the routes. I understand that this is quadratic, but I was
thinking of using some optimizations to limit the calculations. Like
restrict the number of hops from the source node, only calculate the route
to the nearest hub and not every other node, etc.
2. Use Giraph as a real time query engine - The graph is loaded into the
memory of a cluster of nodes, and given the source and destination nodes of
a query, a single source shortest path algorithm is run.
For both these cases, I thought it would be useful have the vertices always
in memory, and only repeat the process from superstep 0 as needed. For
example, every time we have a new query, or every time we need to calculate
a route from a source to a new destination.
On Tue, Sep 25, 2012 at 1:25 AM, Sebastian Schelter <ss...@apache.org> wrote:
> Hi Venkata,
>
> The result of All-Pairs-Shortest-Paths is quadratic in the number of
> vertices which makes it infeasible for sufficiently large graphs.
>
> Best,
> Sebastian
>
>
> On 24.09.2012 20:24, Venkata Sastry Malladi wrote:
> > I'm thinking of modifying the simple shortest paths algorithm so that it
> > calculates the shortest paths between all pairs of nodes (not just from a
> > single source node). I wanted to get some general advice on whether these
> > are feasible in Giraph:
> >
> > 1. Without quitting the job after all vertices voteToHalt(), is it
> possible
> > to just restart from superstep 0, but with a different source node? In
> > other words, when we want to do simultaneous runs of the simple shortest
> > paths algorithm, how can we avoid the overhead of re-reading the graph
> into
> > memory between the runs?
> >
> > 2. Is it possible to run some kind of reducer before the vertices are
> > written to the output? Let's say the VertexWriter outputs something like
> > (Source, Destination) -> Route for each node. Is it possible to combine
> > many such outputs to produce a single output? Like (Source, Destination)
> -
> >> (Route1, Route2, Route3).
> >
> > Thanks,
> > Venkat.
> >
>
>
Re: All pairs shortest paths
Posted by Sebastian Schelter <ss...@apache.org>.
Hi Venkata,
The result of All-Pairs-Shortest-Paths is quadratic in the number of
vertices which makes it infeasible for sufficiently large graphs.
Best,
Sebastian
On 24.09.2012 20:24, Venkata Sastry Malladi wrote:
> I'm thinking of modifying the simple shortest paths algorithm so that it
> calculates the shortest paths between all pairs of nodes (not just from a
> single source node). I wanted to get some general advice on whether these
> are feasible in Giraph:
>
> 1. Without quitting the job after all vertices voteToHalt(), is it possible
> to just restart from superstep 0, but with a different source node? In
> other words, when we want to do simultaneous runs of the simple shortest
> paths algorithm, how can we avoid the overhead of re-reading the graph into
> memory between the runs?
>
> 2. Is it possible to run some kind of reducer before the vertices are
> written to the output? Let's say the VertexWriter outputs something like
> (Source, Destination) -> Route for each node. Is it possible to combine
> many such outputs to produce a single output? Like (Source, Destination) -
>> (Route1, Route2, Route3).
>
> Thanks,
> Venkat.
>