Re: [Neo4j] How to return the start nodes of all the paths with Cypher

2011-11-30 Thread Peter Neubauer
Well,
in Gremlin, it is basically scripting, so you would probably do a loop
and follow the pattern until you are at the right depth, see
http://docs.neo4j.org/chunked/snapshot/gremlin-plugin.html#rest-api-flow-algorithms-with-gremlin
for a flow algo that loops until the target node = sink, without any
hard limitation.

Cheers,

/peter neubauer

GTalk:      neubauer.peter
Skype       peter.neubauer
Phone       +46 704 106975
LinkedIn   http://www.linkedin.com/in/neubauer
Twitter      http://twitter.com/peterneubauer

brew install neo4j && neo4j start
heroku addons:add neo4j



On Wed, Nov 30, 2011 at 11:46 AM, Andres Taylor
 wrote:
> On Wed, Nov 30, 2011 at 11:32 AM, dnagir  wrote:
>
>> I would probably like to write something among these lines (it's not valid
>> query of course):
>>
>>
>> START s=node(10)
>> MATCH p = s<-[:whatever]-t
>> RETURN t, LENGTH(p) as len
>> HAVING len >= MAX( LENGTH(p) )
>>
>
> Well, this query would also return 'b' in the example you shared above. I
> think we need something that says "follow this path until you can't follow
> it any more". If you're working with a B-tree, you should be able to say
> "given this sub-root, give me all leafs". Something like:
>
> START c = node(17)
> MATCH x<-[*END]-c
> RETURN x
>
> I really don't like this syntax, but I think the information belongs in
> there somewhere...
>
> Seems like clause similar to SQL HAVING is missing.
>>
>> It doesn't "exactly" reflect what I want but just thought from top of my
>> head.
>>
>> So currently I have to use other query language if I want to do this.
>> Right?
>
>
> A traversal would do it pretty simply. Maybe someone else can share a
> end-of-graph traversal example?
>
> I'm sure Gremlin can do it as well. Don't know how to do it in Gremlin
> though - Peter, Marko?
>
> Andrés
> ___
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] How to return the start nodes of all the paths with Cypher

2011-11-30 Thread dnagir


On 30/11/2011, at 9:46 PM, Andres Taylor [via Neo4j Community Discussions] 
wrote:

> Well, this query would also return 'b' in the example you shared above.

You're right. Too late here already. Can't think clearly.

> I think we need something that says "follow this path until you can't follow 
> it any more". If you're working with a B-tree, you should be able to say 
> "given this sub-root, give me all leafs".

I don't need all leaves. It's a bit the other way around. I need the root of 
the tree.


> Something like: 
> 
> START c = node(17) 
> MATCH x<-[*END]-c 
> RETURN x 
> I really don't like this syntax, but I think the information belongs in 
> there somewhere... 

I actually don't mind this syntax. It's looks like the right place and clearly 
shows the intent.



--
View this message in context: 
http://neo4j-community-discussions.438527.n3.nabble.com/How-to-return-the-start-nodes-of-all-the-paths-with-Cypher-tp3547480p3547928.html
Sent from the Neo4j Community Discussions mailing list archive at Nabble.com.
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] How to return the start nodes of all the paths with Cypher

2011-11-30 Thread Andres Taylor
On Wed, Nov 30, 2011 at 11:32 AM, dnagir  wrote:

> I would probably like to write something among these lines (it's not valid
> query of course):
>
>
> START s=node(10)
> MATCH p = s<-[:whatever]-t
> RETURN t, LENGTH(p) as len
> HAVING len >= MAX( LENGTH(p) )
>

Well, this query would also return 'b' in the example you shared above. I
think we need something that says "follow this path until you can't follow
it any more". If you're working with a B-tree, you should be able to say
"given this sub-root, give me all leafs". Something like:

START c = node(17)
MATCH x<-[*END]-c
RETURN x

I really don't like this syntax, but I think the information belongs in
there somewhere...

Seems like clause similar to SQL HAVING is missing.
>
> It doesn't "exactly" reflect what I want but just thought from top of my
> head.
>
> So currently I have to use other query language if I want to do this.
> Right?


A traversal would do it pretty simply. Maybe someone else can share a
end-of-graph traversal example?

I'm sure Gremlin can do it as well. Don't know how to do it in Gremlin
though - Peter, Marko?

Andrés
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] How to return the start nodes of all the paths with Cypher

2011-11-30 Thread dnagir
I would probably like to write something among these lines (it's not valid
query of course):


START s=node(10)
MATCH p = s<-[:whatever]-t
RETURN t, LENGTH(p) as len
HAVING len >= MAX( LENGTH(p) )

Seems like clause similar to SQL HAVING is missing.

It doesn't "exactly" reflect what I want but just thought from top of my
head.

So currently I have to use other query language if I want to do this. Right?

--
View this message in context: 
http://neo4j-community-discussions.438527.n3.nabble.com/How-to-return-the-start-nodes-of-all-the-paths-with-Cypher-tp3547480p3547877.html
Sent from the Neo4j Community Discussions mailing list archive at Nabble.com.
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] How to return the start nodes of all the paths with Cypher

2011-11-30 Thread Andres Taylor
On Wed, Nov 30, 2011 at 10:59 AM, Dmytrii Nagirniak wrote:

> Yes, but I don't know the exact paths. Those were just examples. And the
> depth may be higher than 10. So I can't hardcode it into the query.


Ah, now I understand. Sorry about the mix-up...

This is a weak area for Cypher right now. It's in the back log, but nothing
else. If you have any ideas on how to express that, we're always open to
suggestions.

Andrés
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] How to return the start nodes of all the paths with Cypher

2011-11-30 Thread Dmytrii Nagirniak
Yes, but I don't know the exact paths. Those were just examples. And the
depth may be higher than 10. So I can't hardcode it into the query.
On Nov 30, 2011 6:33 PM, "Andres Taylor" 
wrote:

> Hey there,
>
> That looks like a straight forward pattern matching problem, right?
>
> START c=node(1)
> MATCH a-->b-->c, d-->c, d-->b-->c, e-->f-->c
> RETURN a,d,e
>
> This is assuming that you have the node id of c. If not, read up how you do
> an index start point.
>
> Does that help?
>
> Andrés
>
>
> On Wed, Nov 30, 2011 at 7:48 AM, dnagir  wrote:
>
> > Hi,
> >
> > How can I find all the nodes that "start a path"
> >
> > So that I start at node "c" and paths
> > "a->b->c",
> > "d->c",
> > "d->b->c",
> > "e->f->c"
> > I want to retrieve nodes "a", "d" and "e".
> >
> >
> >
> > --
> > View this message in context:
> >
> http://neo4j-community-discussions.438527.n3.nabble.com/How-to-return-the-start-nodes-of-all-the-paths-with-Cypher-tp3547480p3547480.html
> > Sent from the Neo4j Community Discussions mailing list archive at
> > Nabble.com.
> > ___
> > Neo4j mailing list
> > User@lists.neo4j.org
> > https://lists.neo4j.org/mailman/listinfo/user
> >
> ___
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] How to return the start nodes of all the paths with Cypher

2011-11-30 Thread Andres Taylor
On Wed, Nov 30, 2011 at 9:13 AM, Michael Hunger <
michael.hun...@neotechnology.com> wrote:

> what about
>
> start c=node(1)
> match path = c<-[*]->n
> return NODES(path)
>

Ouch... This is probably a rather slow query. It starts from 'c' and goes
all the way out to the end of the graph for, for every path connected from
c. And that could be a LOT of paths. I don't think this is what dnagir was
looking for :)

Andrés
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] How to return the start nodes of all the paths with Cypher

2011-11-30 Thread Michael Hunger
what about

start c=node(1)
match path = c<-[*]->n
return NODES(path)

Returns the end nodes of your paths.

HTH

Michael

Am 30.11.2011 um 08:33 schrieb Andres Taylor:

> Hey there,
> 
> That looks like a straight forward pattern matching problem, right?
> 
> START c=node(1)
> MATCH a-->b-->c, d-->c, d-->b-->c, e-->f-->c
> RETURN a,d,e
> 
> This is assuming that you have the node id of c. If not, read up how you do
> an index start point.
> 
> Does that help?
> 
> Andrés
> 
> 
> On Wed, Nov 30, 2011 at 7:48 AM, dnagir  wrote:
> 
>> Hi,
>> 
>> How can I find all the nodes that "start a path"
>> 
>> So that I start at node "c" and paths
>> "a->b->c",
>> "d->c",
>> "d->b->c",
>> "e->f->c"
>> I want to retrieve nodes "a", "d" and "e".
>> 
>> 
>> 
>> --
>> View this message in context:
>> http://neo4j-community-discussions.438527.n3.nabble.com/How-to-return-the-start-nodes-of-all-the-paths-with-Cypher-tp3547480p3547480.html
>> Sent from the Neo4j Community Discussions mailing list archive at
>> Nabble.com.
>> ___
>> Neo4j mailing list
>> User@lists.neo4j.org
>> https://lists.neo4j.org/mailman/listinfo/user
>> 
> ___
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user

___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] How to return the start nodes of all the paths with Cypher

2011-11-29 Thread Andres Taylor
Hey there,

That looks like a straight forward pattern matching problem, right?

START c=node(1)
MATCH a-->b-->c, d-->c, d-->b-->c, e-->f-->c
RETURN a,d,e

This is assuming that you have the node id of c. If not, read up how you do
an index start point.

Does that help?

Andrés


On Wed, Nov 30, 2011 at 7:48 AM, dnagir  wrote:

> Hi,
>
> How can I find all the nodes that "start a path"
>
> So that I start at node "c" and paths
> "a->b->c",
> "d->c",
> "d->b->c",
> "e->f->c"
> I want to retrieve nodes "a", "d" and "e".
>
>
>
> --
> View this message in context:
> http://neo4j-community-discussions.438527.n3.nabble.com/How-to-return-the-start-nodes-of-all-the-paths-with-Cypher-tp3547480p3547480.html
> Sent from the Neo4j Community Discussions mailing list archive at
> Nabble.com.
> ___
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


[Neo4j] How to return the start nodes of all the paths with Cypher

2011-11-29 Thread dnagir
Hi,

How can I find all the nodes that "start a path"

So that I start at node "c" and paths
"a->b->c", 
"d->c", 
"d->b->c", 
"e->f->c"
I want to retrieve nodes "a", "d" and "e".



--
View this message in context: 
http://neo4j-community-discussions.438527.n3.nabble.com/How-to-return-the-start-nodes-of-all-the-paths-with-Cypher-tp3547480p3547480.html
Sent from the Neo4j Community Discussions mailing list archive at Nabble.com.
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user