Anders and Briegel in Python
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

21 satır
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)