Browse Source

`add_node` is a constant annoyance :rage4:

NetworkX provides `add_node`, we don't, leads to missing
`graph.node["vop"]`. Does this fix it?
master
Pete Shadbolt 8 years ago
parent
commit
352a1d4325
2 changed files with 8 additions and 0 deletions
  1. +5
    -0
      abp/graphstate.py
  2. +3
    -0
      bin/abpserver

+ 5
- 0
abp/graphstate.py View File

@@ -42,6 +42,11 @@ class GraphState(object):
for n in range(data): for n in range(data):
self._add_node(n, vop=vop) self._add_node(n, vop=vop)


def add_node(self, *args, **kwargs):
""" Add a node """
self._add_node(self, *args, **kwargs)


def _add_node(self, node, **kwargs): def _add_node(self, node, **kwargs):
""" Add a node. By default, nodes are initialized with ``vop=``:math:`I`, i.e. they are in the :math:`|+\\rangle` state. """ Add a node. By default, nodes are initialized with ``vop=``:math:`I`, i.e. they are in the :math:`|+\\rangle` state.




+ 3
- 0
bin/abpserver View File

@@ -26,6 +26,9 @@ def new_message(client, server, message):
print edit print edit
else: else:
print "Received update from python {}.".format(client["id"]) print "Received update from python {}.".format(client["id"])
print message
local_state.from_json(json.loads(message))
print local_state
server.send_message_to_all(message) server.send_message_to_all(message)


def new_client(client, server): def new_client(client, server):


Loading…
Cancel
Save