File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -904,23 +904,21 @@ julia> collect(edges(m))
904904```
905905"""
906906@traitfn function mycielski (g:: AbstractGraph :: (!IsDirected) ; iterations = 1 )
907- ref = g
908907 out = deepcopy (g)
909908 for _ in 1 : iterations
910- N = nv (g )
909+ N = nv (out )
911910 add_vertices! (out, N + 1 )
912911 w = nv (out)
913- for e in collect (edges (g ))
914- x, y = Tuple (e)
915- add_edge! (out, x, y)
912+ for e in collect (edges (out ))
913+ x= e . src
914+ y = e . dst
916915 add_edge! (out, x, y+ N)
917916 add_edge! (out, x+ N, y)
918917 end
919918
920919 for v in 1 : N
921920 add_edge! (out, v+ N, w)
922921 end
923- g = out
924922 end
925923 return out
926924end
Original file line number Diff line number Diff line change 329329 @test nv (m) == 767
330330 @test ne (m) == 22196
331331
332+ # ensure it is not done in-place
333+ @test nv (g) == 2
334+ @test ne (g) == 1
335+
332336 # check that mycielski preserves triangle-freeness
333337 g = complete_bipartite_graph (10 , 5 )
334338 m = mycielski (g)
335339 @test nv (m) == 2 * 15 + 1
336340 @test ne (m) == 3 * 50 + 15
337341 @test all (iszero, triangles (m))
342+
343+ # ensure it is not done in-place
344+ @test nv (g) == 15
345+ @test ne (g) == 50
338346 end
339347end
You can’t perform that action at this time.
0 commit comments