Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Iterating over relationships of a specific type
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
vlg  
View profile  
 More options Apr 30 2012, 10:28 am
From: vlg <vince.leguill...@gmail.com>
Date: Mon, 30 Apr 2012 07:28:11 -0700 (PDT)
Local: Mon, Apr 30 2012 10:28 am
Subject: Iterating over relationships of a specific type
Hi there,

Using Neo4j 1.6.2, what would be the best way to iterate over /
retrieve all the relationships of a specific type ?

I guess I could use an index on a property that would store the name
of the relationship type, but this means extra-storage and extra-
operations upon adding edges, so I was wondering if there were any
built-in method to achieve this.

Thanks,
Vincent


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Hunger  
View profile  
 More options Apr 30 2012, 10:42 am
From: Michael Hunger <michael.hun...@neotechnology.com>
Date: Mon, 30 Apr 2012 16:42:56 +0200
Local: Mon, Apr 30 2012 10:42 am
Subject: Re: [Neo4j] Iterating over relationships of a specific type
As this would be a graph global operation it is not supported as of now, it would be even more expensive to do w/o an index.

Without an index you'd have to:

for (Node n : GlobalGraphOperations.at(gdb).getAllNodes()) {
    Relationship rel = n.getRelationships(TYPE,Direction.OUTGOING);
    // do something with the relationship

}

or with cypher:

start n=node(*) match n-[r:TYPE]->() return r

see here for an example: http://tinyurl.com/7ewusrs

Michael

Am 30.04.2012 um 16:28 schrieb vlg:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mattias Persson  
View profile  
 More options May 1 2012, 5:06 am
From: Mattias Persson <matt...@neotechnology.com>
Date: Tue, 1 May 2012 11:06:10 +0200
Local: Tues, May 1 2012 5:06 am
Subject: Re: [Neo4j] Iterating over relationships of a specific type

2012/4/30 Michael Hunger <michael.hun...@neotechnology.com>

> As this would be a graph global operation it is not supported as of now,
> it would be even more expensive to do w/o an index.

> Without an index you'd have to:

> for (Node n : GlobalGraphOperations.at(gdb).getAllNodes()) {
>    Relationship rel = n.getRelationships(TYPE,Direction.OUTGOING);
>    // do something with the relationship
> }

Or (this might be faster since it's a linear scan of the relationship
store, if all relationships aren't already loaded):

for ( Relationship rel :
GlobalGraphOperations.at(gdb).getAllRelationships() ) {
    if ( rel.isType( myType ) ) {
        // do something with the relationship
    }

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

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »