Gremlin Query to give all related items in versioned graph

I am working on a requirement where I need to store all version of a record in a Graph Database say JanusGraph, one naïve approach for this requirement could be to create separate vertex for each record version.

Say: Record R1 has version v1, v2, v3

Then create separate vertex for R1: v1, R2:v2 and R2:v3

But as the record updated multiple times so a Record could have thousands of versions and Graph will become very huge with this kind of approach.

To overcome the above limitation, I am working on another approach to create only one vertex for a Record in Graph database and use HashMap as Edge property to store the version information.

Suppose Record R1 version v1 is related to Record R2 version v1, Record R3 version v2
And Record R2 version v2 is related to Record R2 version v3, Record R3 version v4

For this I am creating an edge property as versionMap which is java.util.HashMap to store the version information

R1 to R2 Edge property contains {v1: v2, v2: v3} that means R1: v1 is related to R2:v2 and R1:v2 is related to R2:v3

So, based on above the Graph could be like this.

Vertex R1, R2, R3, R4

R1-R2 Edge Properties {v1: v2, v2: v3}
R1-R3 Edge Properties {v1:v4, v2: v6}
R2-R4 Edge Properties {v1:v7, v2: v8, v3:v9}

So given the query give me all related records for Record R1 and version v1, I require to write a gremlin query that will return the relationships like this for multiple hops

Relationships R1:v1 = R1:v1 -> R2:v2 ->R4:v8, Is this possible to use the versionMap through Gremlin Query and give the results in above format? Please Suggest
Was this page helpful?