remove_edge Subroutine

private subroutine remove_edge(me, e)

remove an edge index from this vertex

Type Bound

vertex

Arguments

Type IntentOptional Attributes Name
class(vertex), intent(inout) :: me
integer(kind=ip), intent(in) :: e

Called by

proc~~remove_edge~~CalledByGraph proc~remove_edge dag_module::vertex%remove_edge proc~dag_remove_edge dag_module::dag%dag_remove_edge proc~dag_remove_edge->proc~remove_edge proc~dag_remove_node dag_module::dag%dag_remove_node proc~dag_remove_node->proc~remove_edge

Source Code

    subroutine remove_edge(me,e)

    class(vertex),intent(inout) :: me
    integer(ip),intent(in) :: e

    integer(ip),dimension(1) :: idx
    type(edge),dimension(:),allocatable :: tmp

    if (allocated(me%edges)) then
        idx = findloc(me%edges%ivertex, e)
        if (idx(1)>0) then
            ! the edge is in the list
            associate (i => idx(1), n => size(me%edges))
                if (n==1) then
                    deallocate(me%edges) ! it's the only one there
                else
                    allocate(tmp(n-1))
                    if (i>1) tmp(1:i-1) = me%edges(1:i-1)
                    if (i<n) tmp(i:n-1) = me%edges(i+1:n)
                    call move_alloc(tmp,me%edges)
                end if
            end associate
        end if
    end if

    end subroutine remove_edge