Skip to content

Commit 262373b

Browse files
committed
Add tests to verify is_coalesced for various graph transformations
1 parent 773ec4d commit 262373b

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

GNNGraphs/test/transform.jl

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,3 +714,51 @@ end
714714
end
715715
end
716716
end
717+
718+
@testitem "graph transform ops set is_coalesced=false" setup=[GraphsTestModule] begin
719+
using .GraphsTestModule
720+
g = rand_graph(5, 10, graph_type=:coo)
721+
g = coalesce(g) # ensure the graph is coalesced to start with
722+
723+
# add_self_loops
724+
g1 = add_self_loops(g)
725+
@test g1.is_coalesced == false
726+
727+
# remove_self_loops
728+
g2 = add_self_loops(g) # ensure there are self-loops to remove
729+
g2 = remove_self_loops(g2)
730+
@test g2.is_coalesced == false
731+
732+
# remove_edges
733+
g3 = remove_edges(g, [1])
734+
@test g3.is_coalesced == false
735+
736+
# add_edges
737+
g4 = add_edges(g, [1], [2])
738+
@test g4.is_coalesced == false
739+
740+
# perturb_edges
741+
g5 = perturb_edges(g, 0.5)
742+
@test g5.is_coalesced == false
743+
744+
# remove_nodes
745+
g6 = remove_nodes(g, [1])
746+
@test g6.is_coalesced == false
747+
748+
# add_nodes
749+
g7 = add_nodes(g, 2)
750+
@test g7.is_coalesced == false
751+
752+
# rand_edge_split returns two graphs
753+
g8a, g8b = rand_edge_split(g, 0.5)
754+
@test g8a.is_coalesced == false
755+
@test g8b.is_coalesced == false
756+
757+
# negative_sample
758+
g9 = negative_sample(g, num_neg_edges=3)
759+
@test g9.is_coalesced == false
760+
761+
# ppr_diffusion
762+
g11 = ppr_diffusion(g)
763+
@test g11.is_coalesced == false
764+
end

0 commit comments

Comments
 (0)