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

Function LCF_graph

python/graphscope/nx/generators/small.py:100–122  ·  view source on GitHub ↗
(n, shift_list, repeats, create_using=None)

Source from the content-addressed store, hash-verified

98
99@patch_docstring(nxa.LCF_graph)
100def LCF_graph(n, shift_list, repeats, create_using=None):
101 if n <= 0:
102 return empty_graph(0, create_using)
103
104 # start with the n-cycle
105 G = cycle_graph(n, create_using)
106 if G.is_directed():
107 raise NetworkXError("Directed Graph not supported")
108 G.name = "LCF_graph"
109 nodes = sorted(list(G))
110
111 n_extra_edges = repeats * len(shift_list)
112 # edges are added n_extra_edges times
113 # (not all of these need be new)
114 if n_extra_edges < 1:
115 return G
116
117 for i in range(n_extra_edges):
118 shift = shift_list[i % len(shift_list)] # cycle through shift_list
119 v1 = nodes[i % n] # cycle repeatedly through nodes
120 v2 = nodes[(i + shift) % n]
121 G.add_edge(v1, v2)
122 return G
123
124
125# -------------------------------------------------------------------------------

Callers 5

desargues_graphFunction · 0.85
dodecahedral_graphFunction · 0.85
heawood_graphFunction · 0.85
moebius_kantor_graphFunction · 0.85
pappus_graphFunction · 0.85

Calls 4

empty_graphFunction · 0.90
cycle_graphFunction · 0.90
is_directedMethod · 0.45
add_edgeMethod · 0.45

Tested by

no test coverage detected