def visme(G, m=None):
def norm_size(sz):
return int(sz*100)
pos = nx.get_node_attributes(G, "pos")
if not pos:
pos = nx.shell_layout(G)
cut_edges = None
v_colors = ['blue'] * len(G.nodes())
if m:
cut_edges = [e for e in m.E if pyo.value(m.y[e])>0]
val_ = 0
for v in G.nodes():
if m.x[v].value is not None:
val_ = m.x[v].value
if val_ > 0:
v_colors[v] = 'green'
nx.draw_networkx(
G,
pos,
with_labels=True,
edge_color="green",
node_color=v_colors,
node_size=300,
style=':',
width=0.4,
font_size=6
)
if cut_edges:
nx.draw_networkx_edges(
G,
pos,
edgelist=cut_edges,
edge_color="blue",
node_size=200,
width=0.7,
)