Browse Source

Add fancy.GraphState.from_nx, which is a hack

To play around with lattices
master
Pete Shadbolt 8 years ago
parent
commit
dfa0e0c6b8
1 changed files with 10 additions and 0 deletions
  1. +10
    -0
      abp/fancy.py

+ 10
- 0
abp/fancy.py View File

@@ -21,6 +21,15 @@ class GraphState(graphstate.GraphState, networkx.Graph):
except: #TODO: bad practice except: #TODO: bad practice
self.ws = None 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): def shutdown(self):
""" Close the connection to the websocket """ """ Close the connection to the websocket """
if not self.ws: if not self.ws:
@@ -34,6 +43,7 @@ class GraphState(graphstate.GraphState, networkx.Graph):
return return


# Automatically perform layout if position is not provided # Automatically perform layout if position is not provided
print self.node.values()
if not all(("position" in node) for node in self.node.values()): if not all(("position" in node) for node in self.node.values()):
self.layout() self.layout()




Loading…
Cancel
Save