Remove self-loops from the graph.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(graph_type), | intent(inout) | :: | this |
Parent. Instance of the graph structure. |
||
| integer, | intent(in), | optional, | dimension(:) | :: | indices |
Indices of the vertices from which self-loops are removed. |
module subroutine remove_self_loops(this, indices) !! Remove self-loops from the graph. implicit none ! Arguments class(graph_type), intent(inout) :: this !! Parent. Instance of the graph structure. integer, dimension(:), intent(in), optional :: indices !! Indices of the vertices from which self-loops are removed. ! Local variables integer :: i, j !! Loop indices. if(this%num_edges .eq. 0)then write(0,*) 'No edges to remove self-loops from' return end if ! Remove self-loops in reverse order to maintain index validity do i = this%num_edges, 1, -1 if(this%edge(i)%index(1) .eq. this%edge(i)%index(2))then if(present(indices))then if(all(this%edge(i)%index(1) .ne. indices)) cycle end if call this%remove_edges([i], update_adjacency=.false.) end if end do this%has_self_loops = .false. end subroutine remove_self_loops