소스 검색

Magical networkx integration :sparkling_heart:

master
Pete Shadbolt 8 년 전
부모
커밋
513e09b681
4개의 변경된 파일22개의 추가작업 그리고 4개의 파일을 삭제
  1. +1
    -0
      .agignore
  2. +5
    -4
      abp/graphstate.py
  3. +2
    -0
      abp/util.py
  4. +14
    -0
      tests/test_nxgraphstate.py

+ 1
- 0
.agignore 파일 보기

@@ -0,0 +1 @@
static/scripts/three.js

+ 5
- 4
abp/graphstate.py 파일 보기

@@ -6,9 +6,12 @@ import itertools as it
import clifford
import json
import qi
import networkx as nx
try:
from networkx import Graph as NXGraph
except ImportError:
NXGraph = object

class GraphState(object):
class GraphState(NXGraph):

def __init__(self, nodes=[]):
self.adj, self.node = {}, {}
@@ -196,5 +199,3 @@ class GraphState(object):
""" Check equality between graphs """
return self.adj == other.adj and self.node == other.node




+ 2
- 0
abp/util.py 파일 보기

@@ -0,0 +1,2 @@
def xyz(x, y, z=0):
return {"x": x, "y": y, "z": z}

+ 14
- 0
tests/test_nxgraphstate.py 파일 보기

@@ -0,0 +1,14 @@
from abp.graphstate import GraphState
from abp.util import xyz
import networkx as nx

def simple_test():
g = GraphState()
g.add_node(0, xyz(0, 0, 0))
g.add_node(1, xyz(0, 0, 0))
g.act_hadamard(0)
g.act_hadamard(1)
g.act_cz(0, 1)
print g.node[0]["position"]
print nx.to_edgelist(g)


불러오는 중...
취소
저장