File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 6565
6666function remove_self_loops (g:: GNNGraph{<:ADJMAT_T} )
6767 @assert isempty (g. edata)
68- A = g. graph
68+ A = copy ( g. graph)
6969 A[diagind (A)] .= 0
7070 if A isa AbstractSparseMatrix
7171 dropzeros! (A)
Original file line number Diff line number Diff line change 376376 @test size (get_edge_weight (g2)) == (g2. num_edges,)
377377 @test size (g2. edata. e1) == (3 , g2. num_edges)
378378 @test size (g2. edata. e2) == (g2. num_edges,)
379+ else
380+ A = [1 1 0
381+ 0 1 1
382+ 1 0 0 ]
383+ A_no_loops = [0 1 0
384+ 0 0 1
385+ 1 0 0 ]
386+ g = GNNGraph (A; graph_type = GRAPH_T)
387+ g2 = remove_self_loops (g)
388+
389+ @test Matrix (adjacency_matrix (g)) == A
390+ @test Matrix (adjacency_matrix (g2)) == A_no_loops
391+ @test g2. num_edges == count (! iszero, A_no_loops)
392+ @test g. graph != = g2. graph
379393 end
380394 end
381395end
You can’t perform that action at this time.
0 commit comments