MCPcopy Create free account
hub / github.com/FEniCS/dolfinx / plot_graph

Function plot_graph

python/demo/demo_comm-pattern.py:54–83  ·  view source on GitHub ↗

Plot the communication graph.

(G: nx.MultiGraph, egde_labels=False)

Source from the content-addressed store, hash-verified

52
53# +
54def plot_graph(G: nx.MultiGraph, egde_labels=False):
55 """Plot the communication graph."""
56 pos = nx.circular_layout(G)
57 nx.draw_networkx_nodes(G, pos, alpha=0.75)
58 nx.draw_networkx_labels(G, pos, font_size=12)
59
60 width = 0.5
61 edge_color = ["g" if d["local"] == 1 else "grey" for _, _, d in G.edges(data=True)]
62 if egde_labels:
63 # Curve edges to distinguish between in- and out-edges
64 connectstyle = [f"arc3,rad={r}" for r in it.accumulate([0.15] * 4)]
65
66 # Color edges by local (shared memory) or remote (remote memory)
67 # communication
68 nx.draw_networkx_edges(
69 G, pos, width=width, edge_color=edge_color, connectionstyle=connectstyle
70 )
71
72 labels = {tuple(edge): f"{attrs['weight']}" for *edge, attrs in G.edges(data=True)}
73 nx.draw_networkx_edge_labels(
74 G,
75 pos,
76 labels,
77 connectionstyle=connectstyle,
78 label_pos=0.5,
79 font_color="k",
80 bbox={"alpha": 0},
81 )
82 else:
83 nx.draw_networkx_edges(G, pos, width=width, edge_color=edge_color)
84
85
86# -

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected