MCPcopy Create free account
hub / github.com/PythonOT/POT / draw_graph

Function draw_graph

examples/gromov/plot_quantized_gromov_wasserstein.py:134–207  ·  view source on GitHub ↗
(
    G,
    C,
    nodes_color_part,
    rep_indices,
    node_alphas=None,
    pos=None,
    edge_color="black",
    alpha_edge=0.7,
    node_size=None,
    shiftx=0,
    seed=0,
    highlight_rep=False,
)

Source from the content-addressed store, hash-verified

132
133
134def draw_graph(
135 G,
136 C,
137 nodes_color_part,
138 rep_indices,
139 node_alphas=None,
140 pos=None,
141 edge_color="black",
142 alpha_edge=0.7,
143 node_size=None,
144 shiftx=0,
145 seed=0,
146 highlight_rep=False,
147):
148 if pos is None:
149 pos = networkx.spring_layout(G, scale=1.0, seed=seed)
150
151 if shiftx != 0:
152 for k, v in pos.items():
153 v[0] = v[0] + shiftx
154
155 width_edge = 1.5
156
157 if not highlight_rep:
158 networkx.draw_networkx_edges(
159 G, pos, width=width_edge, alpha=alpha_edge, edge_color=edge_color
160 )
161 else:
162 for edge in G.edges:
163 if (edge[0] in rep_indices) and (edge[1] in rep_indices):
164 networkx.draw_networkx_edges(
165 G,
166 pos,
167 edgelist=[edge],
168 width=width_edge,
169 alpha=alpha_edge,
170 edge_color=edge_color,
171 )
172 else:
173 networkx.draw_networkx_edges(
174 G,
175 pos,
176 edgelist=[edge],
177 width=width_edge,
178 alpha=0.2,
179 edge_color=edge_color,
180 )
181
182 for node, node_color in enumerate(nodes_color_part):
183 local_node_shape, local_node_size = "o", node_size
184
185 if highlight_rep:
186 if node in rep_indices:
187 local_node_shape, local_node_size = "*", 6 * node_size
188
189 if node_alphas is None:
190 alpha = 0.9
191 if highlight_rep:

Calls

no outgoing calls

Tested by

no test coverage detected