Why addEdge Step does not Natively supports inserting multiple edges for many start and many end vertexes?

29 views
Skip to first unread message

Stark Arya

unread,
Oct 20, 2022, 10:46:07 AM10/20/22
to Gremlin-users
Lets see some cases based on ModernGrahp:

1.  2 start& 2 end points。just one edge
 Bad case as I think we need to Reimplementation
tmp.png

2. If we need to add 4 edges,the code seems ugly
tmp.png
Does any one have some ideas。

As i know, neo4j will add 4 edges If we use similar neo4j cypher sql

Stephen Mallette

unread,
Oct 20, 2022, 11:01:25 AM10/20/22
to gremli...@googlegroups.com
I think you would prefer the pattern offered by mid-traversal V():

g.V().has('lang', 'java').as('s').
  V().has('lang', 'java').
  addE('link').from('s')




--
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/7b674771-2221-4fb1-8fc7-63a270c49bf6n%40googlegroups.com.

Stark Arya

unread,
Oct 20, 2022, 9:31:03 PM10/20/22
to Gremlin-users
it looks better,but why not try optimize within:
g.addE('work').from(V().has('lang', 'java')).to(V().has('lang', 'java'))

which looks more intuitive

Stephen Mallette

unread,
Oct 23, 2022, 5:00:01 PM10/23/22
to gremli...@googlegroups.com
maybe the best answer i can give is that modulators don't work that way. all modulators take only the first item provided in the stream so making addE work differently would create an inconsistency. I also tend to think the explicit nature of the example I provided doesn't really require any improvement in terms of readability or simplicity, so changing addE just adds yet another way to do something that seems to already have a good approach. 

Stark Arya

unread,
Oct 24, 2022, 12:25:32 AM10/24/22
to Gremlin-users

OK,I known, Thanks @spmal
Reply all
Reply to author
Forward
0 new messages