gremlin> marko = g.V().has('name','marko').next()
gremlin> peter = g.V().has('name','peter').next()
gremlin> g.V(marko).addE('knows').to(peter)
My python script contains:user_1 = g.addV('people').property('name','John').next()
user_2 = g.addV('people').property('name','Mary').next()
g.V(user_1).addE('knows').to(user_2)
people = g.V().valueMap().toList()
connections = g.E().valueMap().toList()
print(people)
print(connections)
As a result I get:[{'name': ['Mary']}, {'name': ['John']}]
[]
Vertices were added without any problem but there is no edge. How can I add an edge using python-gremlin language variant?
--
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/4fcf8ea5-f7e5-4731-ae48-c863f45a0838%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
g.V(user_1).addE('knows').to(user_2).iterate() // or .next() or .toList()
When I add .next()g.V(user_1).addE('knows').to(user_2).next()
I get an error:"{0}: {1}".format(status_code, data["status"]["message"]))
gremlin_python.driver.protocol.GremlinServerError: 599: Could not locate method: DefaultGraphTraversal.to([v[20560]])
On Tuesday, October 10, 2017 at 5:22:14 PM UTC+2, Robert Dale wrote:
The addE() is not iterated like as was done with the addV(). Add .next()
Robert Dale
On Tue, Oct 10, 2017 at 11:18 AM, Tomasz <troj...@gmail.com> wrote:
I want to create simple graph made of two vertices and edge between them.
From the documentation http://tinkerpop.apache.org/docs/current/reference one can read that it could be done as follows:
gremlin> marko = g.V().has('name','marko').next()
gremlin> peter = g.V().has('name','peter').next()
gremlin> g.V(marko).addE('knows').to(peter)
My python script contains:user_1 = g.addV('people').property('name','John').next()
user_2 = g.addV('people').property('name','Mary').next()
g.V(user_1).addE('knows').to(user_2)
people = g.V().valueMap().toList()
connections = g.E().valueMap().toList()
print(people)
print(connections)
As a result I get:[{'name': ['Mary']}, {'name': ['John']}]
[]
Vertices were added without any problem but there is no edge. How can I add an edge using python-gremlin language variant?
--
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/4fcf8ea5-f7e5-4731-ae48-c863f45a0838%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
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/1d81f1c6-9823-4aa4-a845-554753fcaf9c%40googlegroups.com.
Robert Dale
Robert Dale
Robert Dale
user_1 = g.addV('people').property('name','John').next()
user_2 = g.addV('people').property('name','Mary').next()
knows_2_1 = g.V(user_2).addE('knows').to( g.V(user_1) ).next()
knows_1_2 = g.V(user_2).addE('knows').from_( g.V(user_1) ).next()
knows_a_b = g.V(user_1).as_('a').V(user_2).as_('b').addE('knows').from_('a').to('b').next()
--
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/f303c33c-6106-424a-bf29-c41582bb4b3d%40googlegroups.com.
NameError: name 'true' is not defined
valueMap(true) or valueMap(true, property, ...)
Robert Dale
On Tue, Oct 10, 2017 at 5:10 PM, Tomasz <troj...@gmail.com> wrote:
Thank you, Rober and Jason.
Do you know how to return label and properties not only properties?
I can't use TinkerPop 3.3.0 because I use JanusGraph and it supports 3.2.6 version.
By the way, I find Gremlin a little bit weird compared to Cypher from Neo4j but it's probably powerful.
On Tuesday, October 10, 2017 at 11:02:29 PM UTC+2, Jason Plurad wrote:This works in TinkerPop 3.2.6. It looks like to/from has to be a traversal.user_1 = g.addV('people').property('name','John').next()
user_2 = g.addV('people').property('name','Mary').next()knows_2_1 = g.V(user_2).addE('knows').to( g.V(user_1) ).next()knows_1_2 = g.V(user_2).addE('knows').from_( g.V(user_1) ).next()
knows_a_b = g.V(user_1).as_('a').V(user_2).as_('b').addE('knows').from_('a').to('b').next()
FWIW, your original addE() query using the vertex works in TinkerPop 3.3.0.
On Tuesday, October 10, 2017 at 12:19:45 PM UTC-4, Tomasz wrote:.valueMap() maps the properties not a labels, I change line which add egde to: g.V(user_1).addE('knows').property('since','1997').to(__.V(user_2)).next() and now I get [{'since': '1997'}, {}, {}, {}]
--
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.
graph = Graph()
host='localhost';port=8182
remote_conn = "ws://{}:{}/gremlin".format(host, port)
g = graph.traversal().withRemote(DriverRemoteConnection(remote_conn, 'g'))
user_3 = g.V().has('shogun_id','54320').next()
user_4 = g.V().has('content_id','2000005457791').next()
knows_4_3 = g.V(user_4).addE('read').to( g.V(user_3) ).next()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/cliu/.virtenv/lib/python2.7/site-packages/gremlin_python/process/traversal.py", line 70, in next
return self.__next__()
File "/Users/cliu/.virtenv/lib/python2.7/site-packages/gremlin_python/process/traversal.py", line 43, in __next__
self.traversal_strategies.apply_strategies(self)
File "/Users/cliu/.virtenv/lib/python2.7/site-packages/gremlin_python/process/traversal.py", line 353, in apply_strategies
traversal_strategy.apply(traversal)
File "/Users/cliu/.virtenv/lib/python2.7/site-packages/gremlin_python/driver/remote_connection.py", line 143, in apply
remote_traversal = self.remote_connection.submit(traversal.bytecode)
File "/Users/cliu/.virtenv/lib/python2.7/site-packages/gremlin_python/driver/driver_remote_connection.py", line 54, in submit
results = result_set.all().result()
File "/Users/cliu/.virtenv/lib/python2.7/site-packages/concurrent/futures/_base.py", line 429, in result
return self.__get_result()
File "/Users/cliu/.virtenv/lib/python2.7/site-packages/concurrent/futures/_base.py", line 381, in __get_result
raise exception_type, self._exception, self._traceback
gremlin_python.driver.protocol.GremlinServerError: 500: Cannot modify unmodifiable vertex: v[4300]
Robert Dale
In sub-traversals, you need the anonymous __.V().
knows_4_3 = g.V(user_4).addE('read').to(__.V(user_3) ).next()
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/b47744bb-1302-4d5b-99ec-2377b9d330cf%40googlegroups.com.
File "<stdin>", line 1, in <module>
File "/Users/cliu/.virtenv/lib/python2.7/site-packages/gremlin_python/process/traversal.py", line 70, in next
return self.__next__()
File "/Users/cliu/.virtenv/lib/python2.7/site-packages/gremlin_python/process/traversal.py", line 43, in __next__
self.traversal_strategies.apply_strategies(self)
File "/Users/cliu/.virtenv/lib/python2.7/site-packages/gremlin_python/process/traversal.py", line 353, in apply_strategies
traversal_strategy.apply(traversal)
File "/Users/cliu/.virtenv/lib/python2.7/site-packages/gremlin_python/driver/remote_connection.py", line 143, in apply
remote_traversal = self.remote_connection.submit(traversal.bytecode)
File "/Users/cliu/.virtenv/lib/python2.7/site-packages/gremlin_python/driver/driver_remote_connection.py", line 54, in submit
results = result_set.all().result()
File "/Users/cliu/.virtenv/lib/python2.7/site-packages/concurrent/futures/_base.py", line 429, in result
return self.__get_result()
File "/Users/cliu/.virtenv/lib/python2.7/site-packages/concurrent/futures/_base.py", line 381, in __get_result
raise exception_type, self._exception, self._traceback
gremlin_python.driver.protocol.GremlinServerError: 500: Cannot modify unmodifiable vertex: v[4300]
Robert Dale
user_1 = g.addV('people').property('name','yu').next()
user_2 = g.addV('people').property('name','liu').next()
user_1 = g.V().has('name','xx').next()
user_2 = g.V().has('name','yy').next()
knows_1_2 = g.V(user_1).addE('read').to(__.V(user_2) ).next()
Vertex Label | Partitioned | Static
------------ | ----------- | ------
people | false | false
user | false | true
article | false | false
------------ | ----------- | ------
Edge Name | Type | Directed | Unidirected | Multiplicity
--------- | ---- | -------- | ----------- | ------------
know | Edge | true | false | MULTI
knows | Edge | true | false | MULTI
refer | Edge | true | false | MULTI
read | Edge | true | false | MULTI
--------- | ---- | -------- | ----------- | ------------
PropertyKey Name | Type | Cardinality | Data Type
---------------- | ---- | ----------- | ---------
category | PropertyKey | SINGLE | class java.lang.String
name | PropertyKey | SINGLE | class java.lang.String
shogun_id | PropertyKey | SINGLE | class java.lang.String
content_id | PropertyKey | SINGLE | class java.lang.String
ts | PropertyKey | SINGLE | class java.util.Date
---------------- | ---- | ----------- | ---------
Graph Index | Type | Element | Unique | Backing | PropertyKey | Status
----------- | ---- | ------- | ------ | ------- | ----------- | ------
index_by_shogun_id | Composite | JanusGraphVertex | true | internalindex | |
| | | | | shogun_id | INSTALLED
index_by_content_id | Composite | JanusGraphVertex | true | internalindex | |
| | | | | content_id | INSTALLED
---------- | ---- | ------- | ------ | ------- | ----------- | ------
Relation Index | Type | Direction | Sort Key | Sort Order | Status
-------------- | ---- | --------- | ---------- | -------- | ------
-------------- | ---- | --------- | ---------- | -------- | ------
Robert Dale
I'm going to guess that you're using JanusGraph. While you've added some 'people', your query looks for vertexes of different names. I'm guessing that those queries are actually returning 'user's. Your 'user's are static which are not modifiable.
On Friday, December 8, 2017 at 8:58:11 AM UTC-5, Eric Cyliu wrote:
I created two new "people" and found them using g.V().has(.......).next(). And then add edge. It worked.So I am thinking that the error might relate to indexing as shogun_id and content_id were indexed and unique. But there is nothing wrong with indexing vertices.I am also attaching the schema.
user_1 = g.addV('people').property('name','xx').next()
user_2 = g.addV('people').property('name','yy').next()