Hi. I am new to Gremlin-Tinkerpop 3. I am reading through the documentation of Tinkerpop 3 and feel a little overwhelmed. I am looking to create a gremlin query that can return all the nodes and edges in a k-hop ego network of a node, where the definition of a k-hop ego network of a node is (1) all the neighbors (and edges) within k hops when performing breadth-first-search from this node, and (2) all edges between the nodes in this network. I am not sure how I can achieve this with a gremlin query (or any Tinkerpop 3 alternative such as vertexprogram). The tricky part seems to be (2).Can anyone help me out here? Many thanks!!
--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/dcaee5c9-1de9-4c6f-ae90-3987450e1ab7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
It would be great if the result puts all (unique) vertices into a list, and all (unique) edges into another list
--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/f597d771-3d82-4f05-991e-a4980ac29022%40googlegroups.com.
... request the traversal to only go through up to Y edges of each vertex
g.V(1).emit().repeat(local(bothE().limit(Y)).dedup().store("edges").otherV()
).times(hops).dedup().aggregate("vertices").bothE().where(without("edges")).as("edge").otherV().where(within("vertices")).select("edge").store("edges").cap("vertices", "edges")
request the traversal to stop when the number of vertices in the ego network reaches a threshold X
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/74c287e6-cba1-44b5-9ff1-af0cc85eb7a6%40googlegroups.com.
For limiting the total number of vertices, is it possible to use limit(X) following aggregate("vertices")
gremlin> g.V(1).out()==>v[3]==>v[2]==>v[4]gremlin> g.V(1).out().aggregate("x").limit(1).cap("x").unfold()==>v[3]==>v[2]==>v[4]
can I use sample(X) in place of limit(X)?
Similarly can I use local(bothE().sample(Y))?
Is sample a lot slower than limit?
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/ced45177-6f36-4ee3-81c6-7e30af817032%40googlegroups.com.
{
"nodes":[
{"id":"6","name":"peter","age":35},
{"id":"5","name":"ripple","lang":"java"},
{"id":"3","name":"lop","lang":"java"},
{"id":"4","name":"josh","age":32},
{"id":"2","name":"vadas","age":27},
{"id":"1","name":"marko","age":29}
],
"edges":[
{"source":"1","target":"2","eid":"0","label":"knows","weight":0.500000},
{"source":"1","target":"4","eid":"2","label":"knows","weight":1.000000},
{"source":"1","target":"3","eid":"1","label":"created","weight":0.400000},
{"source":"4","target":"3","eid":"3","label":"created","weight":0.400000},
{"source":"4","target":"5","eid":"4","label":"created","weight":1.000000},
{"source":"6","target":"3","eid":"5","label":"created","weight":0.200000}
],
"summary":[{"number of nodes":6,"number of edges":6}],
}