Refactor Graph class to use __getstate__ and
__setstate__ methods
This commit is contained in:
parent
6877fdbdc7
commit
81279853a0
1 changed files with 4 additions and 4 deletions
|
|
@ -34,11 +34,11 @@ class Graph:
|
||||||
self._edges = self._graph_data["edges"]
|
self._edges = self._graph_data["edges"]
|
||||||
self._build_graph()
|
self._build_graph()
|
||||||
|
|
||||||
|
def __getstate__(self):
|
||||||
|
return self.raw_graph_data
|
||||||
|
|
||||||
def __setstate__(self, state):
|
def __setstate__(self, state):
|
||||||
self.__dict__.update(state)
|
self.__init__(**state)
|
||||||
for edge in self.edges:
|
|
||||||
edge.reset()
|
|
||||||
edge.validate_edge()
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_payload(cls, payload: Dict) -> "Graph":
|
def from_payload(cls, payload: Dict) -> "Graph":
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue