Cost evaluator - cost depending on multiple relationships

24 views
Skip to first unread message

Martin Uhlir

unread,
Mar 27, 2015, 2:25:24 AM3/27/15
to ne...@googlegroups.com
Hi,

I'm trying to use TraversalAStar to find the shortest path in my graph. The problem I'm facing is that I need a cost evaluator which doesn't depend only on the current relationship being evaluated, but I need to take into consideration even one previous relationship (if there is any).

I'm trying to implement CostEvaluator<Double> interface which has following signature:

public interface CostEvaluator<T> {
    T getCost( Relationship relationship, Direction direction );
}

What I actually need in the getCost() method is, to have an access to the relationship prior this relationship (or more generally to the whole path up to this relationship).

"Drawing" a picture as following:

(A)--REL1-->(B)--REL2-->(C)--REL3-->(D)

When the cost evaluator is being triggered on the REL3 relationship, I need access to the properties of the REL2 as well, to be able to properly calculate the cost for REL3. Any idea how I can achieve that?

Thanks for any help.
Reply all
Reply to author
Forward
0 new messages