Skip to content

Commit 7c3a4db

Browse files
authored
Update graph.py
1 parent 821867a commit 7c3a4db

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

cyaron/graph.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ def chain(point_count, **kwargs):
106106
bool directed = True -> whether the chain is directed(true:directed,false:not directed)
107107
(int,int) weight_limit = (1,1) -> the limit of weight. index 0 is the min limit, and index 1 is the max limit(both included)
108108
int weight_limit -> If you use a int for this arg, it means the max limit of the weight(included)
109+
int/float weight_gen()
110+
= lambda: random.randint(weight_limit[0], weight_limit[1])
111+
-> the generator of the weights. It should return the weight. The default way is to use the random.randint()
109112
"""
110113
return Graph.tree(point_count, 1, 0, **kwargs)
111114

@@ -118,6 +121,9 @@ def flower(point_count, **kwargs):
118121
bool directed = True -> whether the chain is directed(true:directed,false:not directed)
119122
(int,int) weight_limit = (1,1) -> the limit of weight. index 0 is the min limit, and index 1 is the max limit(both included)
120123
int weight_limit -> If you use a int for this arg, it means the max limit of the weight(included)
124+
int/float weight_gen()
125+
= lambda: random.randint(weight_limit[0], weight_limit[1])
126+
-> the generator of the weights. It should return the weight. The default way is to use the random.randint()
121127
"""
122128
return Graph.tree(point_count, 0, 1, **kwargs)
123129

@@ -126,16 +132,16 @@ def tree(point_count, chain=0, flower=0, **kwargs):
126132
"""tree(point_count, chain=0, flower=0, **kwargs) -> Graph
127133
Factory method. Return a tree with point_count vertexes.
128134
int point_count -> the count of vertexes
129-
bool chain = 0 -> whether the tree is a chain
130-
bool flower = 0 -> whether the tree is a flower
135+
float chain = 0 -> 1 means the tree is a chain
136+
float flower = 0 -> 1 means the tree is a flower
131137
NOTICE:only either chain or flower can be True
132138
**kwargs(Keyword args):
133139
bool directed = False -> whether the chain is directed(true:directed,false:not directed)
134140
(int,int) weight_limit = (1,1) -> the limit of weight. index 0 is the min limit, and index 1 is the max limit(both included)
135141
int weight_limit -> If you use a int for this arg, it means the max limit of the weight(included)
136-
int weight_gen()
142+
int/float weight_gen()
137143
= lambda: random.randint(weight_limit[0], weight_limit[1])
138-
-> the generator of the weights. It should return a weight between weight_limit[0] and [1]. The default way is to use the random.randint()
144+
-> the generator of the weights. It should return the weight. The default way is to use the random.randint()
139145
"""
140146
directed = kwargs.get("directed", False)
141147
weight_limit = kwargs.get("weight_limit", (1, 1))
@@ -181,9 +187,9 @@ def binary_tree(point_count, left=0, right=0, **kwargs):
181187
bool directed = False -> whether the chain is directed(true:directed,false:not directed)
182188
(int,int) weight_limit = (1,1) -> the limit of weight. index 0 is the min limit, and index 1 is the max limit(both included)
183189
int weight_limit -> If you use a int for this arg, it means the max limit of the weight(included)
184-
int weight_gen()
190+
int/float weight_gen()
185191
= lambda: random.randint(weight_limit[0], weight_limit[1])
186-
-> the generator of the weights. It should return a weight between weight_limit[0] and [1]. The default way is to use the random.randint()
192+
-> the generator of the weights. It should return the weight. The default way is to use the random.randint()
187193
"""
188194
directed = kwargs.get("directed", False)
189195
weight_limit = kwargs.get("weight_limit", (1, 1))
@@ -228,6 +234,9 @@ def graph(point_count, edge_count, **kwargs):
228234
bool directed = False -> whether the chain is directed(true:directed,false:not directed)
229235
(int,int) weight_limit = (1,1) -> the limit of weight. index 0 is the min limit, and index 1 is the max limit(both included)
230236
int weight_limit -> If you use a int for this arg, it means the max limit of the weight(included)
237+
int/float weight_gen()
238+
= lambda: random.randint(weight_limit[0], weight_limit[1])
239+
-> the generator of the weights. It should return the weight. The default way is to use the random.randint()
231240
"""
232241
directed = kwargs.get("directed", False)
233242
weight_limit = kwargs.get("weight_limit", (1, 1))
@@ -254,7 +263,9 @@ def hack_spfa(point_count, **kwargs):
254263
(int,int) weight_limit = (1,1) -> the limit of weight. index 0 is the min limit, and index 1 is the max limit(both included)
255264
int weight_limit -> If you use a int for this arg, it means the max limit of the weight(included)
256265
int extra_edge = 2 -> the number of extra edges
257-
266+
int/float weight_gen()
267+
= lambda: random.randint(weight_limit[0], weight_limit[1])
268+
-> the generator of the weights. It should return the weight. The default way is to use the random.randint()
258269
"""
259270
directed = kwargs.get("directed", False)
260271
extraedg = kwargs.get("extra_edge", 2)

0 commit comments

Comments
 (0)