Skip to content

Commit e8334df

Browse files
Introduce a snapshot system that automatically saves graph states using real-time timestamps.
1 parent ed88315 commit e8334df

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

pydatastructs/graphs/graph.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
__all__ = [
55
'Graph'
66
]
7-
7+
import copy
8+
import time
89
class Graph(object):
910
"""
1011
Represents generic concept of graphs.
@@ -87,7 +88,12 @@ def __new__(cls, *args, **kwargs):
8788
else:
8889
raise NotImplementedError("%s implementation is not a part "
8990
"of the library currently."%(implementation))
90-
91+
obj.snapshots = {}
92+
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+
9197
def is_adjacent(self, node1, node2):
9298
"""
9399
Checks if the nodes with the given

0 commit comments

Comments
 (0)