Keeping track of edges between neighbor nodes

27 views
Skip to first unread message

NMS

unread,
Jan 9, 2014, 7:48:45 AM1/9/14
to dex...@googlegroups.com
Hi,

My task is to retrieve a small subgraph from a graph...

The user enters a query node and a number "n" that represents the number of hubs required... The required subgraph is the query node and it's neighbors up to "n" hops... i.e. growing neighborhoods around the query node up to "n" hops...

I managed to create the database, fill it, and find the user query node by using:
Objects *query1 = g->Select(person, Equal, v.SetString(q1));
I also managed to retrieve the query neighbors by:
Objects *query2 = g->Neighbors(query1, knows, Any);
I have placed the above statement in a loop that loops "n" times in order to get the neighbors up to "n" hubs... I used the CombineUnion function to combine the neighbors from all levels... as a result I got the neighbors of the user query node up to "n" hups... But I couldn't find a function that gets the edges (the edges between the neighbor nodes)... Is there one? is there an efficient way to do it?

I only can think of one un-efficient solution:
Objects *query2 = g->Neighbors(query1, knows, Any);
and then using an iterator that traverses the nodes inside query2 (lets say node "0" and node "1") and do the following:
edge 1 = q1 and 0
edge 2 = q1 and 1
and then use the neighbors function twice once to retrieve the neighbors of node "0" and another to retrieve the neighbors of node "1" and so on!!!

Please let me know if there is an efficient solution...

Best regards,
Nouf

c3po.ac

unread,
Jan 9, 2014, 9:14:35 AM1/9/14
to dex...@googlegroups.com

Hi,

If you want the edge identifiers it may be better to use the "Explode" method instead of "Neighbors".
For each node, you find it's edges with explode. Then you can easily get the other node of each edge iterating the result and using the "GetEdgePeer" operation for each one (with the source node used in the explode and the edge id as arguments).

Best regards.

El dijous 9 de gener de 2014 13:48:45 UTC+1, NMS va escriure:

NMS

unread,
Jan 12, 2014, 3:05:44 AM1/12/14
to dex...@googlegroups.com
Thank you very much...
Reply all
Reply to author
Forward
0 new messages