The Dijkstra algorithm continues until it finds the end node. It could
easily be modified to not stop there, just exhaust the graph and output it's
entire set instead. Look at:


https://github.com/neo4j/community/blob/master/graph-algo/src/main/java/org/neo4j/graphalgo/impl/path/Dijkstra.java

...and I'd rewrite the findAllPaths method to something like:

    public Iterable<WeightedPath> findAllPaths( Node start, final Node end )
    {
        final Traverser traverser = TRAVERSAL.expand( expander ).order(
                new SelectorFactory( costEvaluator ) ).traverse( start );
        return new Iterable<WeightedPath>()
        {
            public Iterator<WeightedPath> iterator()
            {
                return new StopAfterWeightIterator( traverser.iterator(),
                        costEvaluator );
            }
        };
    }

and also in:


https://github.com/neo4j/community/blob/master/graph-algo/src/main/java/org/neo4j/graphalgo/impl/util/StopAfterWeightIterator.java

I'd rewrite fetchNextOrNull to something like (of course, by then the class
name would not be true anymore :) ):

    protected WeightedPath fetchNextOrNull()
    {
        if ( !paths.hasNext() )
        {
            return null;
        }
        return new WeightedPathImpl( costEvaluator, paths.next() );
    }

These are just thoughts, but they ought to work right out out of this box.

Best,
Mattias

2011/6/20 Giacomo Bernardi <[email protected]>

> I'm not sure I understand your answer.
>
> What I'd like to build is a graph where every node that is not a
> source has a shortest path to any one of the sources.
>
> Any idea?
>
> I see that neo4j's Dijkstra implementation requires to specify a start
> AND and end node. Isn't there at least a version that calculates the
> path for a start node and every other end node?
>
> Thanks!
>
>
> On 20 June 2011 03:53, Akhil <[email protected]> wrote:
> > On 6/19/2011 7:11 PM, Giacomo Bernardi wrote:
> >> I'd like to build a second graph in which each e in (S-E) is connected
> >  From what i understood, connecting S-E to an arbitary node A1 and S
> > with another arbitary node A2 and finding the lowest cost shortest path
> > between A1 and A2 should give you the solution
> > _______________________________________________
> > Neo4j mailing list
> > [email protected]
> > https://lists.neo4j.org/mailman/listinfo/user
> >
>
>
>
> --
> Giacomo "mino" Bernardi
> _______________________________________________
> Neo4j mailing list
> [email protected]
> https://lists.neo4j.org/mailman/listinfo/user
>



-- 
Mattias Persson, [[email protected]]
Hacker, Neo Technology
www.neotechnology.com
_______________________________________________
Neo4j mailing list
[email protected]
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to