Path finding from a Relation

22 views
Skip to first unread message

Yuval

unread,
Oct 2, 2012, 7:01:52 PM10/2/12
to ne...@googlegroups.com

Is it possible to to start a path search from a relation rather than a node? 
The way we modeled are data, it turns out we have several use cases where the user chooses the relation rather than the node. 


Wes Freeman

unread,
Oct 2, 2012, 7:07:47 PM10/2/12
to ne...@googlegroups.com
You can do something like this:

start r=relationship(3) 
match p=n-[r]-()-[:KNOWS]-m 
return p;


Is that what you mean?

Wes

On Tue, Oct 2, 2012 at 7:01 PM, Yuval <yuval...@gmail.com> wrote:

Is it possible to to start a path search from a relation rather than a node? 
The way we modeled are data, it turns out we have several use cases where the user chooses the relation rather than the node. 


--
 
 

Yuval

unread,
Oct 2, 2012, 7:14:45 PM10/2/12
to ne...@googlegroups.com
Might very well be but I will need some assistance deciphering your answer (pardon the newbiness :-)

Wes Freeman

unread,
Oct 2, 2012, 7:17:51 PM10/2/12
to ne...@googlegroups.com
Commented example!

// given a known relationship -- can also do index lookup here
START r=relationship(3)  
// find all paths that have that relationship and then a :KNOWS relationship 
// (just an example--if you want something closer to your real use case, set it up in console and we can take a look)
MATCH p=()-[r]-()-[:KNOWS]-() 
// return those paths
RETURN p;

On Tue, Oct 2, 2012 at 7:14 PM, Yuval <yuval...@gmail.com> wrote:
Might very well be but I will need some assistance deciphering your answer (pardon the newbiness :-)

--



Yuval Perlov

unread,
Oct 2, 2012, 7:23:24 PM10/2/12
to ne...@googlegroups.com
Okay, i think i get it. I've been using the java API directly till now. Does it translate?  For these types of queries, should i rather use cypher?
--
 
 

Wes Freeman

unread,
Oct 2, 2012, 7:30:47 PM10/2/12
to ne...@googlegroups.com
I only know Cypher myself--am clueless about most of the APIs and stuff like Gremlin, and I've only been looking at graph databases for a couple of months, so take my opinion with a grain of salt. So, with that disclaimer, my opinion is biased, but I think you should use Cypher!

Anyone else?

In case you hadn't seen it, a quick example of Cypher through Java:

--
 
 

Peter Neubauer

unread,
Oct 3, 2012, 12:01:37 AM10/3/12
to ne...@googlegroups.com
Yves,
I would say Cypher is far more productive and readable then the Java API. However, if you need the last bit of fine grained control, then either the core API (iterators) or the Traversal API are your friends, since right now they provide more low-level access to the traversals than Cypher.

/peter
--
 
 


--

Cheers,

/peter neubauer

G:  neubauer.peter
S:  peter.neubauer
P:  +46 704 106975
L:   http://www.linkedin.com/in/neubauer
T:   @peterneubauer

Wanna learn something new? Come to http://graphconnect.com

Eugeny Kozhanov

unread,
Oct 3, 2012, 1:24:49 AM10/3/12
to ne...@googlegroups.com
It's my way:
1) set to start relationship flag "start"
2) finding path from one node with RelTypeFilterExcluder({"start"}) (it's your class which ignored "start" relationship, for example: http://vinger4.blogspot.com/2012/10/neo4j-class-reltypefilterexcluder.html)
3) finding path from other node with same RelTypeFilterExcluder.
4) join two results
Reply all
Reply to author
Forward
0 new messages