Raise RuntimeError("Some nodes do not have a type") NdColours.append(colours) % len(colours)]) Layout = nx.spring_layout(G, k = 4 / math.sqrt(len(G.nodes()))) > Default `False`, if `True` labels will be added to the nodes giving their IDs. This looks a bit nicer than the one provided my _networkx_'s defaults. """Just makes a simple _matplotlib_ figure and displays it, with each node coloured by its type. Nx.draw_networkx_edges(g, pos, edgelist=, width=weight, edge - in_nodes] * 1.5, ax=ax) Nx.draw_networkx_nodes(g, pos, nodelist=range(in_nodes, in_nodes + out_nodes), node_color='b', node_size=50, ax=ax) Nx.draw_networkx_nodes(g, pos, nodelist=range(in_nodes), node_color='r', node_size=50, ax=ax) Pos.update((n, (3, i)) for i, n in zip(height_out_y, Y)) # put nodes from Y at x=2 Pos.update((n, (1, i)) for i, n in zip(height_in_y, X)) # put nodes from X at x=1 Height_out_y = np.linspace((height_in - height_out) / 2, height_out, out_nodes) Height_in_y = np.linspace(0, height_in, in_nodes) G = nx._bipartite_graph(in_nodes,out_nodes) Def graph_att_head(M, N, weight, ax, title):
0 Comments
Leave a Reply. |