@@ -79,10 +79,9 @@ def to_str(self, **kwargs):
7979 **kwargs(Keyword args):
8080 bool shuffle = False -> whether shuffle the output or not
8181 str output(Edge) = str -> the convert function which converts object Edge to str. the default way is to use str()
82- list[int] node_shuffler(list[ int] )
83- = lambda table : random.sample(table, k=len(table) )
82+ list[int] node_shuffler(int)
83+ = lambda n : random.sample(range(1, n + 1), k=n )
8484 -> the random function which shuffles the vertex sequence.
85- Note that this function will actually be passed in a `range`!
8685 list[Edge] edge_shuffler(list[Edge])
8786 -> a random function. the default is to shuffle the edge sequence,
8887 also, if the graph is undirected, it will swap `u` and `v` randomly.
@@ -96,10 +95,10 @@ def _edge_shuffler_default(table):
9695
9796 shuffle = kwargs .get ("shuffle" , False )
9897 output = kwargs .get ("output" , str )
99- node_shuffler = kwargs .get ("node_shuffler" , lambda table : random .sample (table , k = len ( table ) ))
98+ node_shuffler = kwargs .get ("node_shuffler" , lambda n : random .sample (range ( 1 , n + 1 ), k = n ))
10099 edge_shuffler = kwargs .get ("edge_shuffler" , _edge_shuffler_default )
101100 if shuffle :
102- new_node_id = [0 ] + node_shuffler (range ( 1 , len ( self .edges ) ))
101+ new_node_id = [0 ] + node_shuffler (self .vertex_count ( ))
103102 edge_buf = []
104103 for edge in self .iterate_edges ():
105104 edge_buf .append (
0 commit comments