Anders and Briegel in Python
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

20 linhas
667B

  1. import networkx as nx
  2. import numpy as np
  3. import graphstate
  4. import clifford
  5. import util
  6. class NXGraphState(graphstate.GraphState, nx.Graph):
  7. """ This is GraphState with NetworkX-like abilities """
  8. def __init__(self, *args, **kwargs):
  9. graphstate.GraphState.__init__(self, *args, **kwargs)
  10. def layout(self):
  11. """ Automatically lay out the graph """
  12. pos = nx.spring_layout(self, dim=3, scale=np.sqrt(self.order()))
  13. middle = np.average(pos.values(), axis=0)
  14. pos = {key: value - middle for key, value in pos.items()}
  15. for key, (x, y, z) in pos.items():
  16. self.node[key]["position"] = util.xyz(x, y, z)