Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
09-20-2021 04:37 AM
I am currently exploring solutions to model a network graph with multiple dynamic properties between nodes. I do not want to simply store a specific snapshot of the graph but the evolution of the graph over time. Properties change rapidly (seconds or less resolution).
For example I want to track the datarate.
(n :Node)-[ :DATARATE{'value': 10, 'timestamp': 12345678}]->(m :Node)
Then I want to be able to get the current state of the graph (only consider the edges with the most recent timestamps) but also for an arbitrary timestamp.
Edges are only updated when something changes, so its not just a query for a specific timestamp, but the most recent timestamp up until a specific point.
The question now is if neo4j is suited for this kind of data and queries. In my very basic research I did not find a solution to query the datarate relation for the latest update.
I looked into timetrees, but they seem to be deprecated and also not ideal for this kind of problem.
Does someone have any hints or directions I could further investigate?
09-20-2021 02:28 PM
Could a model like this suits your need?
Following this model, you could introduce lineup nodes and represent variation of your states at different moments in time. You would have the latest "updated" node pointing to a head node (most recent timestamp) and the other to a historical node (old timestamp). With it you could easily find the most recent one and fast.
You could also delete the relationships past a certain threshold to keep your database from expanding indefinitely.
09-20-2021 08:10 PM
Q1: time evolution:
step # 1: n:Node assuming the Node has a property, 'name' = 'X' and at timestamp '12345678' has a DATARATE relation with m:Node say m.name = 'Y'
step # 2: n:Node with timestamp
'12345688'. At this timestamp are you expecting Node 'n' to be in relation with Node 'm' with name 'Y' or with Node 'm' with name say 'Z'?
Since you are not saving the previous state of Node 'n', I don't know how you can determine the time evolution.
09-21-2021 07:09 AM
The solution provided above help you keep track of your states by keeping the previous state of your node, node (n-1), pointing to the historical node and keeping all its relationships intact. The new version, node (n), is a newly created node with a relationship pointing to the head node.
For the question at step #2, I would expect n:Node with timestamp '12345688' to be in relation with Node 'm' with name 'Z'. However, the timestamp would not be part of the node or relationship property but rather part of the historical node, say t:Node with a property 'timestamp': 12345688. You could find n:Node by filtering on the historical node for a specific timestamp, and look at the relationship attached that points to m:Node.
Filtering on the head node (most recent version) would be faster as there would only be one with a specific label (e.g., current).
Another option would be to keep track of your relationship and everything by adding a new property, as follow:
(n :Node)-[ :DATARATE{'value': 10, 'timestamp': 12345688, 'state': new}]->(z :Node)
(n :Node)-[ :DATARATE{'value': 10, 'timestamp': 12345678, 'state': old}]->(m :Node)
You can improve the performance by indexing the property with a b-tree index ( Index configuration - Operations Manual (neo4j.com)
09-21-2021 07:53 AM
Hello Maximilian
The problem you indicated could be modelled by adding updated timestamp property to Node under preview.You can sort the nodes based on updatedTimestamp property and retrieve your own series of Nodes based on your logic.This is kind of a mini mimicry of Time series Database but you need to deft in crafting a write query for your design.
Thanking you
Yours
Sameer Gijare
All the sessions of the conference are now available online