Anders and Briegel in Python
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

20 wiersze
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)