gremlin - Common ancestor in a titan graph.. -


in titan(hbase) graph, common ancestors given nodes. using gremlin there way can common ancestors? or other utils / libs available find common ancestors in titan graph given nodes?

i'll make assumptions on you're looking here, maybe answer inspire come looking for. used toy graph demonstrate approach , assumed edges directionally pointed children. isn't perfect tree, there's enough data there @ least demonstrate traversal. following shows "children" whom wanted find ancestors:

gremlin> g = tinkergraphfactory.createtinkergraph() ==>tinkergraph[vertices:6 edges:6] gremlin> children = [g.v(2),g.v(5),g.v(6)] ==>v[2] ==>v[5] ==>v[6] 

i can recursively loop through tree through ancestors , see paths follows:

gremlin> children._().in.loop(1){it.loops<5}{true}.path ==>[v[2], v[1]] ==>[v[5], v[4]] ==>[v[5], v[4], v[1]] 

the above line caps loop @ 5 steps away ancestor , {true} closure means output values @ steps of loop. common ancestor 1 each path terminates more once:

gremlin> children._().in.loop(1){it.loops<5}{true}.groupcount.cap.next().findall{it.value>1} ==>v[1]=2 

in sense v[1] common ancestor among 3 child nodes , 2 of 3 child nodes share ancestor. make more interesting, let's connect vertex 6 vertex 4 , re-execute traversal:

gremlin> children._().in.loop(1){it.loops<5}{true}.groupcount.cap.next().findall{it.value>1} ==>v[1]=3 ==>v[4]=2 

now vertex 4 included common ancestor. has children of vertex 6 , 5. given shared nature of vertex 4, 6 share vertex 1 ancestor shared 3 vertices.


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -