check_weights Function

private function check_weights(graph, err) result(ok)

Reject negative edge weights, on which Dijkstra and A* are invalid.

Arguments

Type IntentOptional Attributes Name
type(csr_t), intent(in) :: graph

Adjacency matrix whose stored values are the edge weights

type(error_t), intent(out), optional :: err

Return Value logical

.true. when every stored weight is non-negative


Calls

proc~~check_weights~~CallsGraph proc~check_weights check_weights proc~csr_nnz csr_t%csr_nnz proc~check_weights->proc~csr_nnz proc~fail fail proc~check_weights->proc~fail proc~error_set error_t%error_set proc~fail->proc~error_set

Called by

proc~~check_weights~~CalledByGraph proc~check_weights check_weights proc~a_star a_star proc~a_star->proc~check_weights proc~dijkstra dijkstra proc~dijkstra->proc~check_weights proc~path_cost path_cost proc~path_cost->proc~check_weights

Variables

Type Visibility Attributes Name Initial
integer(kind=default_int), private :: k

Source Code

   function check_weights(graph, err) result(ok)
      !! Reject negative edge weights, on which Dijkstra and A* are invalid.
      type(csr_t), intent(in) :: graph
         !! Adjacency matrix whose stored values are the edge weights
      type(error_t), intent(out), optional :: err
      logical :: ok
         !! `.true.` when every stored weight is non-negative

      integer(default_int) :: k

      ok = .false.
      do k = 1, graph%nnz()
         if (graph%values(k) < 0.0_dp) then
            call fail(err, "pic_graph: negative edge weights are not supported by Dijkstra or A*")
            return
         end if
      end do
      ok = .true.
   end function check_weights