We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e8334df commit ce5ca83Copy full SHA for ce5ca83
pydatastructs/graphs/graph.py
@@ -93,6 +93,13 @@ def add_snapshot(self):
93
"""Automatically assigns timestamps using system time."""
94
timestamp = int(time.time()) # Secure real-time timestamp
95
self.snapshots[timestamp] = copy.deepcopy(self)
96
+ def get_snapshot(self, timestamp: int):
97
+ """Retrieves a past version of the graph if the timestamp exists."""
98
+ if timestamp not in self.snapshots:
99
+ raise ValueError(f"Snapshot for timestamp {timestamp} does not exist. "
100
+ f"Available timestamps: {sorted(self.snapshots.keys())}")
101
+
102
+ return self.snapshots[timestamp]
103
104
def is_adjacent(self, node1, node2):
105
"""
0 commit comments