0

I am trying to find the best way to model time varying graph in neo4j. The current model use a time variable "year" in the relationship to capture the time. For example,

(A)-[year:2000]->(B)-[year:2000]->(C)

(A)-[year:2000]->(D)-[value:2000]->(E)

(A)-[year:1999]->(B)-[year:1999]->(C)

(A)-[year:1999]->(D)

CREATE (a:firm {name:'A'}), (b:firm {name:'B'}), (c:firm {name:'C'}), 
(d:firm {name:'D'}), (e:firm {name:'E'}),
(a)-[:REL {year: 2000}]->(b)->[:REL {year: 2000}]->(c),
(a)-[:REL {year: 2000}]->(d)->[:REL {year: 2000}]->(e),
(a)-[:REL {year: 1999}]->(b)->[:REL {year: 1999}]->(c),
(a)-[:REL {year: 1999}]->(d);

We are modeling this way because the original database stores the bilateral relationship by year. This is definitely not a space-efficient way to store a time varying graph. If space is not our concern, is this a reasonable way to model a time varying graph?

In this case, is it possible to get the difference between two years, i.e., (D)-[value:2000]->(E)?

(I have read Neo4j time dependent graph model but it seems outdated.)

cccfran
  • 83
  • 1
  • 9
  • you could also store the year as relationship type instead of relationship property, should be more performant AFAIK. WDYM with the difference? – Tomaž Bratanič Nov 11 '21 at 18:32
  • @TomažBratanič Thanks. How does the relationship type differ from relationship property in terms of performance? The difference between 1999 and 2000 is the relationship (D)-[value:2000]->(E). What is the proper cypher query for this? – cccfran Nov 11 '21 at 19:12

0 Answers0