From dfa0e0c6b8954a0e9eaa4bcd47735e50c83b11f3 Mon Sep 17 00:00:00 2001 From: Pete Shadbolt Date: Thu, 18 Aug 2016 12:45:47 +0100 Subject: [PATCH] Add fancy.GraphState.from_nx, which is a hack To play around with lattices --- abp/fancy.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/abp/fancy.py b/abp/fancy.py index 3178596..6468f13 100644 --- a/abp/fancy.py +++ b/abp/fancy.py @@ -21,6 +21,15 @@ class GraphState(graphstate.GraphState, networkx.Graph): except: #TODO: bad practice self.ws = None + def from_nx(self, g): + """ Clone from a networkx graph. Hacky af """ + self.adj = g.adj.copy() + self.node = g.node.copy() + # TODO: hacky af + for key, value in self.node.items(): + self.node[key]["vop"] = clifford.by_name["identity"] + + def shutdown(self): """ Close the connection to the websocket """ if not self.ws: @@ -34,6 +43,7 @@ class GraphState(graphstate.GraphState, networkx.Graph): return # Automatically perform layout if position is not provided + print self.node.values() if not all(("position" in node) for node in self.node.values()): self.layout()