Coldfire
Coldfire
ATApache TinkerPop
Created by Coldfire on 12/10/2024 in #questions
Parameterized edges creation in existing graph
Hi :gremlin_smile: , I'm currently experimenting with Janusgraph. My graph is a directed hierachical graph coming straight from parsing an XML file. After this first bulk load, I want to add multiple new edges between vertices to create shortcuts or remove property duplication. This was easily done using Cypher and a double MATCH but struggle to do the same thing in Gremlin. I created a small dataset in Gremlify https://gremlify.com/jf036ue70jj/4
g.V()
.hasLabel('E')
.as('e')
.local(
// this first block alone returns only 6 pairs i,j
select('e').values('bName').as('i').
select('e').values('cName').as('j').
select('i', 'j')

// matching corresponding B->C vertices does not work (48 results)
.V()
.hasLabel('B').has('name', select('i')).as('b')
.out('has').has('name', select('j')).as('c')
//addE 'connected' from 'e' to 'c'
.select('e', 'b', 'c')
)
g.V()
.hasLabel('E')
.as('e')
.local(
// this first block alone returns only 6 pairs i,j
select('e').values('bName').as('i').
select('e').values('cName').as('j').
select('i', 'j')

// matching corresponding B->C vertices does not work (48 results)
.V()
.hasLabel('B').has('name', select('i')).as('b')
.out('has').has('name', select('j')).as('c')
//addE 'connected' from 'e' to 'c'
.select('e', 'b', 'c')
)
I tried project(), local(), combinations of select() and map() but I think I'm missing something really basic. Thanks :furnace:
11 replies