MCPcopy Create free account
hub / github.com/alibaba/GraphScope / lollipop_graph

Function lollipop_graph

python/graphscope/nx/generators/classic.py:269–292  ·  view source on GitHub ↗
(m, n, create_using=None)

Source from the content-addressed store, hash-verified

267@nodes_or_number([0, 1])
268@patch_docstring(nxa.lollipop_graph)
269def lollipop_graph(m, n, create_using=None):
270 m, m_nodes = m
271 n, n_nodes = n
272 M = len(m_nodes)
273 N = len(n_nodes)
274 if isinstance(m, int):
275 n_nodes = [len(m_nodes) + i for i in n_nodes]
276 if M < 2:
277 raise NetworkXError("Invalid graph description, m should be >=2")
278 if N < 0:
279 raise NetworkXError("Invalid graph description, n should be >=0")
280
281 # the ball
282 G = complete_graph(m_nodes, create_using)
283 if G.is_directed():
284 raise NetworkXError("Directed Graph not supported")
285 # the stick
286 G.add_nodes_from(n_nodes)
287 if N > 1:
288 G.add_edges_from(pairwise(n_nodes))
289 # connect ball to stick
290 if M > 0 and N > 0:
291 G.add_edge(m_nodes[-1], n_nodes[0])
292 return G
293
294
295@patch_docstring(nxa.null_graph)

Callers

nothing calls this directly

Calls 5

complete_graphFunction · 0.85
add_nodes_fromMethod · 0.80
add_edges_fromMethod · 0.80
is_directedMethod · 0.45
add_edgeMethod · 0.45

Tested by

no test coverage detected