yeah because if the model graph is changed, the way to return filter also 
changes. For example:
In your case here:
CREATE (Pontus:People { name:'Pontus Lundin' }),(John:People { name: 'John 
Hellberg' }),(Jack:People { name: 'Jack Hellberg' }),(Sandra:People { name: 
'Sandra 
Johansson', sex:'female' }),(Fredrik:People { name:'Fredrik Hansson' }),(
Nils:People { name:'Nils Poppe' }),(Pontus)-[:FRIEND]->(Jack),(Jack)-[:
FRIEND]->(Sandra),(John)-[:FRIEND]->(Jack),(Jack)-[:FRIEND]->(John),(Sandra
)-[:FRIEND]->(Fredrik),(Fredrik)-[:FRIEND]->(Ronny),(Pontus)-[:FRIEND]->(
John),(Pontus)-[:FRIEND]->(Fredrik),(Sandra)-[:FRIEND]->(Nils);

your Traversal Api will work well:
POST 
http://localhost:7474/db/data/node/0/traverse/node{"order":"breadth_first","uniqueness":"node_global","prune_evaluator":{"name":"none","language":"builtin"},
 
"return_filter":{ "body":"position.length()>2", "language":"javascript" }, 
"relationships":{"direction":"out","type":"FRIEND"},"max_depth":3}

But in my case here:
User | Friends
 1   | 9,2,8,7,5
 2   | 1,6,3,8,10
 3   | 5,7,1,10,2
 4   | 3,10,6,9,5
 5   | 4,8,1,9,3
 6   | 7,9,3,2,10
 7   | 9,5,10,6,8
 8   | 6,9,1,10,5
 9   | 6,5,10,1,8
 10  | 8,6,4,5,9

with your Traversal Api it will not work, it will return null instead 
because you set position.length() > 2. But if I set position.length() > 1, 
it will work well:
POST http://localhost:7474/db/data/node/1/traverse/node 
{"order":"breadth_first","uniqueness":"node_global","prune_evaluator":{"name":"none","language":"builtin"},
 
"return_filter":{ "body":"position.length()>1", "language":"javascript" }, 
"relationships":{"direction":"out","type":"Friend"},"max_depth":3}

And if I have graph that has structure like tree:
User | Friends
 A   | B,C,Q
 B   | A,E,D
 C   | A,G,F
 D   | B,H
 E   | B,J,I
 F   | C
 G   | C,L,K
 H   | D,N,M
 I   | E
 J   | E
 K   | G,O
 L   | G
 M   | H,P
 N   | H,Q
 O   | K,R
 P   | M,A
 Q   | N,A
 R   | O,A

with your Traversal Api it will work well while mine is not.

That's why I said it works sometimes. So maybe you have a solution for this 
case?

Thank you.


On Saturday, April 5, 2014 7:43:06 AM UTC+7, Lundin wrote:
>
> First, why do you say it works sometimes ? That sounds like a bug to me in 
> that case. Can you please start with a small dataset so you know and being 
> sure that you know whats going on in the graph ?
>
> CREATE (Pontus:People { name:'Pontus Lundin' }),(John:People { name: 'John 
> Hellberg' }),(Jack:People { name: 'Jack Hellberg' }),(Sandra:People { name: 
> 'Sandra Johansson', sex:'female' }),(Fredrik:People { name:'Fredrik 
> Hansson' }),(Nils:People { name:'Nils Poppe' 
> }),(Pontus)-[:FRIEND]->(Jack),(Jack)-[:FRIEND]->(Sandra),(John)-[:FRIEND]->(Jack),(Jack)-[:FRIEND]->(John),(Sandra)-[:FRIEND]->(Fredrik),(Fredrik)-[:FRIEND]->(Ronny),(Pontus)-[:FRIEND]->(John),(Pontus)-[:FRIEND]->(Fredrik),(Sandra)-[:FRIEND]->(Nils);
>
> This creates a graph with fof where i would like to query for fof where i 
> am not already friend with.
>
> POST 
> http://localhost:7474/db/data/node/0/traverse/node{"order":"breadth_first","uniqueness":"node_global","prune_evaluator":{"name":"none","language":"builtin"},
>  
> "return_filter":{ "body":"position.length()>2", "language":"javascript" }, 
> "relationships":{"direction":"out","type":"FRIEND"},"max_depth":3}
>
> Will return Nils Poppe which is a friend to Sandra. Sandra is also Friend 
> to Fredrik but i am already friend to him so he is excluded.
>
> As for your second question i dont know if that is possible with the REST 
> API i dont think so
> The actual docs for path is
> http://components.neo4j.org/neo4j/2.0.1/apidocs/org/neo4j/graphdb/Path.html
>
> but you will have to use cypher and do yet another query and a simple 
> query like this will return the number:
>
> MATCH (n)-[r]-(friends)
> RETURN count(r), type(r);
>
>
>
> Den lördagen den 5:e april 2014 kl. 02:25:48 UTC+2 skrev Rio Eduardo:
>>
>> Lundin, Do you know the way how to count many relationships in the graph 
>> because I don't see it in the doc(method for the position object(the path))?
>>
>> Thank you.
>>
>> On Saturday, April 5, 2014 12:43:01 AM UTC+7, Lundin wrote:
>>>
>>> Have you tried experimenting with ther filter and the path length ?
>>> endNod() is not the only method for the position object(the path), Mabey 
>>> position.length>1 or something.
>>>
>>> Den fredagen den 4:e april 2014 kl. 18:10:33 UTC+2 skrev Rio Eduardo:
>>>>
>>>> Please anyone in this group help me. I already posted my problem at
>>>>
>>>>
>>>> http://stackoverflow.com/questions/22861424/neo4j-traversal-to-find-friends-of-friends-that-are-not-friends-with-the-user
>>>>
>>>> Thank you.
>>>>
>>>

-- 
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