Gremlin-python subGraph becomes a dict instead of a graph.

322 views
Skip to first unread message

Olav Laudy

unread,
Jan 2, 2018, 6:01:59 PM1/2/18
to Gremlin-users
Hi,

Gremlin 3.3.1 with corresponding Gremlin-Python, playing with the Modern-graph.

g.E().hasLabel('knows').subgraph('subGraph').cap('subGraph').next() gives:

{u'@type': u'tinker:graph',
 u'@value': {u'edges': [e[7][1-knows->2], e[8][1-knows->4]],
  u'vertices': [v[1], v[2], v[4]]}}

Per console instruction:

gremlin> subGraph = g.E().hasLabel('knows').subgraph('subGraph').cap('subGraph').next() 
\ ==>tinkergraph[vertices:3 edges:2] gremlin> sg = subGraph.traversal() ==>graphtraversalsource[tinkergraph[vertices:3 edges:2], standard]

I cast to Python:

subGraph= g.E().hasLabel('knows').subgraph('subGraph').cap('subGraph').next()
sg = subGraph.traversal()

to receive:

AttributeError: 'dict' object has no attribute 'traversal'


How do I create a graph object from this so I can do subsequent queries, as per console:

gremlin> sg.E()



Thanks!

Stephen Mallette

unread,
Jan 3, 2018, 9:15:47 AM1/3/18
to Gremlin-users
subgraph() isn't well supported in the GLVs. i've made a note to improve documentation there. the problem is that GLVs deal with "reference" graph elements (elements that don't have properties) and there is no Graph class in GLVs to convert the returned subgraph to. I think you would want to return edge lists instead - I think that's the best workaround that i can think of.

--
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-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/2deb7049-8475-4eed-99a4-f9917bbeccb1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages