@@ -82,18 +82,15 @@ def __new__(cls, *args, **kwargs):
82
82
from pydatastructs .graphs .adjacency_list import AdjacencyList
83
83
obj = AdjacencyList (* args )
84
84
obj ._impl = implementation
85
-
86
85
elif implementation == 'adjacency_matrix' :
87
86
from pydatastructs .graphs .adjacency_matrix import AdjacencyMatrix
88
87
obj = AdjacencyMatrix (* args )
89
88
obj ._impl = implementation
90
-
91
89
else :
92
90
raise NotImplementedError ("%s implementation is not a part "
93
91
"of the library currently." % (implementation ))
94
92
obj ._impl = implementation
95
- obj .snapshots = {}
96
-
93
+ obj .snapshots = {}
97
94
def add_snapshot (self ):
98
95
"""Automatically assigns timestamps using system time."""
99
96
timestamp = int (time .time ())
@@ -112,19 +109,14 @@ def get_snapshot(self, timestamp: int):
112
109
if timestamp not in self .snapshots :
113
110
raise ValueError (f"Snapshot for timestamp { timestamp } does not exist. "
114
111
f"Available timestamps: { sorted (self .snapshots .keys ())} " )
115
-
116
112
return self .snapshots [timestamp ]
117
113
def list_snapshots (self ):
118
114
"""Returns all stored timestamps in sorted order."""
119
115
return sorted (self .snapshots .keys ())
120
-
121
-
122
116
obj .add_snapshot = add_snapshot .__get__ (obj )
123
117
obj .get_snapshot = get_snapshot .__get__ (obj )
124
118
obj .list_snapshots = list_snapshots .__get__ (obj )
125
119
return obj
126
-
127
-
128
120
def is_adjacent (self , node1 , node2 ):
129
121
"""
130
122
Checks if the nodes with the given
0 commit comments