Combine multiple connected components based on a node having same property

41 zobrazení
Přeskočit na první nepřečtenou zprávu

Shaoor Jan

nepřečteno,
4. 8. 2021 12:07:1804.08.21
komu: Gremlin-users
Hi, 
I am new to gremlin and would appreciate some help. 

Sample data: 
g.addE('Executed').from(g.addV('User').property(id, 'u1')).to(g.addV('Query').property(id, 'q1')).next()
g.addE('Executed').from(g.V().has(id, 'u1')).to(g.addV('Query').property(id, 'q2')).next()
g.addE('Join').from(g.V().has(id, 'q1')).to(g.addV('Table').property("name", "table_1")).next()
g.addE('Join').from(g.V().has("name", 'table_1')).to(g.addV('Table').property("name", "table_2")).next()
g.addE('Join').from(g.V().has(id, 'q2')).to(g.addV('Table').property("name", "table_2")).next()

g.addE('Executed').from(g.addV('User').property(id, 'u2')).to(g.addV('Query').property(id, 'q3')).next()
g.addE('Join').from(g.V().has(id, 'q3')).to(g.addV('Table').property("name", "table_2")).next()
g.V().hasLabel('User')

I have attached two images: 
  1. The first image (img_1) shows the graph I have, It can be created by using the command given above.
  2. The second image (img_2) shows the desired output. 
I want to combine all the table nodes with the same "name" property and get the connected component. The final result must be a "Path" so that I can visualize it in Jupyter Notebook.

Thank you! 
img_1 .png
img_2.png

HadoopMarc

nepřečteno,
5. 8. 2021 2:19:4805.08.21
komu: Gremlin-users
Hi,

Probably, you do not want to create duplicate nodes in the first place, see:

Merging nodes after duplication is a fact (e.g. due to imported graphs with io.reader) is quite complicated. One could get some inspiration from:

Best wishes,    Marc

Op woensdag 4 augustus 2021 om 18:07:18 UTC+2 schreef jansh...@gmail.com:
Odpovědět všem
Odpověď autorovi
Přeposlat
0 nových zpráv