There's a limiter in Dijkstra and A* that will stop the iterator after all
paths with the lowest cost (if there are multiple) have been returned. This
could and probably should be changed to allow for returning paths with
diminishing cost as long as the user of the iterator pulls items.


2014-03-23 14:39 GMT+01:00 Antonio Grimaldi <antonio.grimaldim...@gmail.com>
:

> Hi Michael,
> thanks for your answer.
> I tried to use WeightedPath path = dijkstraPath.findAllPaths(startNode,
> endNode);
> But always one path is returned, except when there are two or more paths
> with the same cost.
> Instead i would like to found the firts 3 alternative path, with different
> cost.
>
> Antonio Grimaldi
>
>
> Il giorno venerdì 21 marzo 2014 17:26:21 UTC+1, Antonio Grimaldi ha
> scritto:
>
>> Hi,
>> I used the Dijkstra algorithm to compute the path between two nodes in
>> the graph, in this way :
>>
>>
>> CostEvaluator<Double> costEvaluator = null;
>> if(costProperty.equalsIgnoreCase(IConstants.EDGE_LENGTH_PROPERTY)){
>>   //In questo caso bisogna eseguire il calcolo del percorso più breve
>> (minore distanza percorsa)
>>   costEvaluator = CommonEvaluators.doubleCostEvaluator( costProperty );
>> }else if(costProperty.equalsIgnoreCase(IConstants.EDGE_SPEED_PROPERTY)){
>>   //In questo caso bisogna eseguire il calcolo del percorso più rapido
>> (minore rapporto distanza/velocità)
>>   costEvaluator = new CostEvaluator<Double>() {
>>   @Override
>>   public Double getCost(Relationship relationship, Direction direction) {
>>        Double edgeLength = (Double) relationship.getProperty(
>> IConstants.EDGE_LENGTH_PROPERTY);
>>        Long edgeSpeed = (Long) relationship.getProperty(
>> IConstants.EDGE_SPEED_PROPERTY);
>>        Double cost = edgeLength / edgeSpeed;
>>        return cost.doubleValue();
>>     }
>>
>> };
>>
>>   }
>> PathFinder<WeightedPath> dijkstraPath = GraphAlgoFactory.dijkstra(
>> PathExpanders.forTypeAndDirection(relationType, Direction.OUTGOING),
>> costEvaluator);
>> WeightedPath path = dijkstraPath.findSinglePath(startNode, endNode);
>>
>> So, I can calculate the shortest route or the quickest route by 
>> costProperty's
>> value...
>>
>> Now, I need to make the same considerations, whit shortestPath algoritm,
>> because I would to retrieve the first N = 3 paths found.
>>
>> I tried using :
>> PathFinder<Path> simplePaths = GraphAlgoFactory.shortestPath(
>> PathExpanders.forTypeAndDirection(relationType, Direction.OUTGOING),
>> 1000000, 3);
>> Iterable<Path> paths = simplePaths.findAllPaths(startNode, endNode);
>>
>> but this not manage my "costProperty".
>>
>> Is there a way to retrieve the first N = 3 paths found, whit an algoritm
>> that manage  "costProperty", like Dijkstra?
>>
>> Thanks
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Neo4j" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to neo4j+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



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

-- 
You received this message because you are subscribed to the Google Groups 
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to neo4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to