I doubt that you currently can do it efficiently with a pure cypher
solution for your graph size, so I'd recommed to look into the Java
Traversal or Core-API for that.

For your general questions: default weights:

with r, case type(r) when "FOO" then 1 when "BAR" then 2 else 0 end as
weight

your query could look like something like this, not sure how that performs
in a large graph,
would be interesting to see in a graph like yours, esp. with 2.1. and
CYPHER 2.1.experimental prefix

if you have a data-generator you might try it.

MATCH p=(n:Node {id:124})-[rels*..10]->(m)
WITH m, reduce(weight = 1, r in rels | weight * case type(r) when "FOO"
then 1 when "BAR" then 2 else 0.5 end) as weight
ORDER BY WEIGHT ASC
LIMIT 10




On Fri, Jun 6, 2014 at 7:03 AM, Terenzio Treccani <
[email protected]> wrote:

> I need to find the N nodes "nearest" to a given node in a graph, meaning
> the ones with least combined weight of relationships along the path from
> given node.
> Is is possible to do so with a pure Cypher only solution? I was looking
> about path functions but couldn't find a viable way to express my query.
>
> Moreover, is it possible to assign a default weight to a relationship at
> query time, according to its type/label (or somehow else map the
> relationship type to the weight)? The idea is to experiment with different
> weights without having to change a property for every relationship.
> Otherwise I would have to change the weight property's value to each
> relationship and re-do it to before each query, which is very
> time-consuming (my graph has around 10M relationships).
> Again, a pure Cypher solution would be the best, or please point me in the
> right direction.
>
> Any help/comment appreciated!
> Thanks in advance
>
> --
> 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 [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to