Skip to content

Materialize

All of the view functions mentioned hold zero updates of their own, simply providing a lens through which to look at the original graph you ingested into. This is by design so that we can have many of them without our machines exploding from data duplication.

This does mean, however, if the original graph is updated, all of the views over it will also update. If you do not want this to happen you may materialize() a view, creating a new graph and duplicating all the updates the view contains into it.

Below we can see an example of this where we create a windowed view between the 17th and 18th of June and then materialize this. After adding a new monkey interaction in the graph, we can see the original view now contains this new update, but our materialized one does not.

start_time = datetime.strptime("2019-06-17", "%Y-%m-%d")
end_time = datetime.strptime("2019-06-18", "%Y-%m-%d")
windowed_view = g.window(start_time, end_time)
materialized_view = windowed_view.materialize()
print(
    f"Before the update the view had {windowed_view.count_temporal_edges()} edge updates"
)
print(
    f"Before the update the materialized view had {materialized_view.count_temporal_edges()} edge updates"
)
g.add_edge(start_time, "FELIPE", "LOME", properties={"Weight": 1}, layer="Grooming")
print(
    f"After the update the view had {windowed_view.count_temporal_edges()} edge updates"
)
print(
    f"After the update the materialized view had {materialized_view.count_temporal_edges()} edge updates"
)

Output

Before the update the view had 132 edge updates
Before the update the materialized view had 132 edge updates
After the update the view had 133 edge updates
After the update the materialized view had 132 edge updates