File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1158,23 +1158,21 @@ julia> collect(edges(m))
11581158```
11591159"""
11601160@traitfn function mycielski (g:: AbstractGraph :: (!IsDirected) ; iterations = 1 )
1161- ref = g
11621161 out = deepcopy (g)
11631162 for _ in 1 : iterations
1164- N = nv (g )
1163+ N = nv (out )
11651164 add_vertices! (out, N + 1 )
11661165 w = nv (out)
1167- for e in collect (edges (g ))
1168- x, y = Tuple (e)
1169- add_edge! (out, x, y)
1166+ for e in collect (edges (out ))
1167+ x= e . src
1168+ y = e . dst
11701169 add_edge! (out, x, y+ N)
11711170 add_edge! (out, x+ N, y)
11721171 end
11731172
11741173 for v in 1 : N
11751174 add_edge! (out, v+ N, w)
11761175 end
1177- g = out
11781176 end
11791177 return out
11801178end
Original file line number Diff line number Diff line change 378378 @test nv (m) == 767
379379 @test ne (m) == 22196
380380
381+ # ensure it is not done in-place
382+ @test nv (g) == 2
383+ @test ne (g) == 1
384+
381385 # check that mycielski preserves triangle-freeness
382386 g = complete_bipartite_graph (10 , 5 )
383387 m = mycielski (g)
384388 @test nv (m) == 2 * 15 + 1
385389 @test ne (m) == 3 * 50 + 15
386390 @test all (iszero, triangles (m))
391+
392+ # ensure it is not done in-place
393+ @test nv (g) == 15
394+ @test ne (g) == 50
387395 end
388396end
You can’t perform that action at this time.
0 commit comments