dijkstra Subroutine

subroutine dijkstra(u, inext)

Arguments

Type IntentOptional Attributes Name
integer(kind=ip), intent(in) :: u
integer(kind=ip), intent(in) :: inext

Called by

proc~~dijkstra~~CalledByGraph proc~dijkstra problem_23::dijkstra proc~go~5 problem_23::go proc~go~5->proc~dijkstra program~problem_23 problem_23 program~problem_23->proc~go~5

Source Code

    subroutine dijkstra(u, inext)
        integer(ip),intent(in) :: u ! current
        integer(ip),intent(in) :: inext ! index in inext array of the next node
        integer(ip) :: idist

        associate (next_node             => nodes(u)%inext(inext), &
                   distance_to_next_node => nodes(u)%idist(inext))

            if (nodes_visited(next_node)) return ! already visited this one

            idist = node_dist(u) + distance_to_next_node ! add distance from u to v

            if (idist > node_dist(next_node)) then
                !write(*,*) 'highest so far: ', idist
                node_dist(next_node) = idist
                node_prev(next_node) = u
            end if

        end associate

    end subroutine dijkstra