Reject negative edge weights, on which Dijkstra and A* are invalid.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(csr_t), | intent(in) | :: | graph |
Adjacency matrix whose stored values are the edge weights |
||
| type(error_t), | intent(out), | optional | :: | err |
.true. when every stored weight is non-negative
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer(kind=default_int), | private | :: | k |
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