Intiial BranchState in AStar Traversal

81 views
Skip to first unread message

nw31304

unread,
Nov 26, 2012, 9:55:20 PM11/26/12
to ne...@googlegroups.com

Mattias Persson

unread,
Nov 27, 2012, 2:49:32 AM11/27/12
to Neo4j Development
Hi,

right that hasn't been added since the A* implementation exposed in GraphAlgoFactory isn't backed by the traversal framework. There's a less tested TraversalAStar implementation that could be updated to take an InitialBranchState in the constructor. If I add that, could you try it out?


2012/11/17 nw31304 <david.ni...@gmail.com>
Newbie here.  I am trying to implement a stateful AStar traversal in Neo4J using the Java embedded API.  That is, I'd like to pass an object which holds some contextual information gathered down a branch to use in selecting/pruning onward relationships once I've arrived at a certain node in the graph.  This works well with the Dijkstra traversal, as the GraphAlgoFactory has a dijkstra-producing factory method which supports setting an initial state:

dijkstra(PathExpander expander, InitialStateFactory stateFactory, String relationshipPropertyRepresentingCost)

Great.  However, I cannot find a corresponding factory method to set the initial state in an AStar traversal, and my findSinglePath() invocaton meets an untimely end with:

java.lang.UnsupportedOperationException: Branch state disabled, pass in an initial state to enable it
        at org.neo4j.kernel.Traversal$1.getState(Traversal.java:100)[neo4j-kernel-1.8.jar:1.8]

So how does one "pass in an initial state" sans a InitialStateFactory parameter on the factory method?  Looking at post 1.8 API docs seems to reveal no answer, either.

Thanks in advance, and apologies in advance as well if the answer to this is obvious to everyone except me.

--
 
 



--
Mattias Persson, [mat...@neotechnology.com]
Hacker, Neo Technology
www.neotechnology.com

nw31304

unread,
Nov 27, 2012, 4:29:16 AM11/27/12
to ne...@googlegroups.com
Thanks for the reply. Its a relief that I wasn't missing something obvious. I'd be delighted to exercise the code. In the meantime, I implemented a "poor man's AStar" by simply reordering edges in the Pathexpander.expand() within the Dijkstra search based on distance to the goal node. That at least gave me access to the state object, but it's a poor substitute for a proper AStar. Thanks again, and I look forward to being able to give the new AStar a try.

Mattias Persson

unread,
Mar 11, 2013, 2:54:57 AM3/11/13
to Neo4j Development
I just saw this old thread. There's now a constructor in TraversalAStar class that accepts PathExpander/InitialBranchState. It's in latest development version of Neo4j at least, and will be included in 1.9.


2012/11/27 nw31304 <david.ni...@gmail.com>
Thanks for the reply. Its a relief that I wasn't missing something obvious. I'd be delighted to exercise the code. In the meantime, I implemented a "poor man's AStar" by simply reordering edges in the Pathexpander.expand() within the Dijkstra search based on distance to the goal node.  That at least gave me access to the state object, but it's a poor substitute for a proper AStar.  Thanks again, and I look forward to being able to give the new AStar a try.

--


Reply all
Reply to author
Forward
0 new messages