5 A cluster graph is a networkx graph with nodes holding a letter "type 6 code" (c,w,b,s,m) and a code-dependent data structure 11 return True if all keys of want are in have and all their values are equal. 16 if have[w] != want[w]:
22 Add some indexing and lookups to meta data on cluster graph vertices 33 for node, data
in gr.nodes.data():
34 if data[
'code'] ==
'c':
35 self.
_id2ch[data[
'ident']] = node
36 self.
_pi2ch[(data[
'wpid'], data[
'index'])] = node;
38 if data[
'code'] ==
'w':
39 self.
_cs2wire[(data[
'chid'], data[
'seg'])] = node
40 self.
_wip2wire[(data[
'wpid'], data[
'index'])] = node;
41 self.
_wid2wire[(data[
'wpid'], data[
'ident'])] = node;
46 Return a channel node by a key. If key is scalar it is a 47 channel ident number, else assumed to be a pair of (wpid, 50 if type(key) == tuple:
56 Return a wire node by its channel and segment 62 Return a wire node by its wire-in-plane number in the given wire-plane ID 68 Return a wire node by its wire-ident and wire-plane ID. 73 def find(self, typecode=None, **kwds):
75 Return nodes with data matching kwds. If typecode is given, 76 only consider nodes of that type. 79 for node,data
in self.gr.nodes.data():
80 if typecode
and self.gr.nodes[node][
'code'] != typecode:
90 Return a list of nodes of given type code 92 return [n
for n,d
in self.gr.nodes.data()
if d[
'code'] == typecode]
96 Return all connected nodes of the given node and given type. 99 for nn
in self.
gr[node]:
100 if self.gr.nodes[nn][
'code'] == typecode:
def neighbors_oftype(self, node, typecode)
def nodes_oftype(self, typecode)
def wire_wip(self, wpid, wip)
def find(self, typecode=None, kwds)
def match_dict(have, want)
def wire_wid(self, wpid, wid)
def wire_chanseg(self, chan, seg)