Anders and Briegel in Python
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

21 lignes
745B

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