139 'Plot all wib connections' 141 newG = networkx.Graph()
144 conn_colors = [
'xkcd:sky blue',
'xkcd:deep pink',
145 'xkcd:sky blue',
'xkcd:deep pink']
148 return (-2 + slot - 0.5, 0)
149 def conn_pos(slot, conn):
151 square_pts = [(-1,-1), (1,-1), (1,1), (-1,1)]
152 line_pts = [(0,-2),(0,-1),(0,1),(0,2)]
157 return (wp[0]+scale*pt[0], wp[1]+scale*pt[1])
158 def board_pos(side, spot):
160 return (-5 + spot, -3)
161 return (4 - spot, +3)
166 nwib =
"w%d"%(
int(wib[3:])+1,)
167 newG.add_node(nwib, color=
"xkcd:white", shape=
'o')
170 islot = G[apa][wib][
'slot']
171 newP[nwib] = wib_pos(islot)
172 boards_on_wib = graph.neighbors_by_type(G, wib,
'board')
173 for board
in boards_on_wib:
174 face = list(graph.neighbors_by_type(G, board,
'face'))[0]
175 ispot = G[face][board][
'spot']
177 iside = G[face][apa][
'side']
178 nboard =
"b%d"%(
int(board[5:])+1,)
180 iconn = G[wib][board][
'connector']
181 nconn =
"%d%d" % (islot+1, iconn+1)
182 newG.add_node(nconn, color=conn_colors[iconn], shape=
'd')
183 newP[nconn] = conn_pos(islot, iconn)
185 newG.add_node(nboard, color=conn_colors[iconn], shape=
's')
186 newP[nboard] = board_pos(iside, ispot)
188 newG.add_edge(nwib,nconn)
189 newG.add_edge(nconn,nboard)
192 colors = [n[1][
'color']
for n
in newG.nodes(data=
True)]
193 shapes = [n[1][
'shape']
for n
in newG.nodes(data=
True)]
195 networkx.draw(newG, pos=newP,
200 plt.savefig(
'test_plot_wib.pdf')