Validate the structural preconditions shared by every algorithm here.
The adjacency must be a structurally sound csr_t, square, non-empty,
small enough for a vertex index to fit the heap’s int32 payload,
and source must be a real vertex.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(csr_t), | intent(in) | :: | graph |
Adjacency matrix to check |
||
| integer(kind=default_int), | intent(in) | :: | source |
Vertex index that must lie in |
||
| type(error_t), | intent(out), | optional | :: | err |
.true. when the graph and vertex are usable
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer(kind=default_int), | private | :: | n |
function check_graph(graph, source, err) result(ok) !! Validate the structural preconditions shared by every algorithm here. !! !! The adjacency must be a structurally sound `csr_t`, square, non-empty, !! small enough for a vertex index to fit the heap's `int32` payload, !! and `source` must be a real vertex. type(csr_t), intent(in) :: graph !! Adjacency matrix to check integer(default_int), intent(in) :: source !! Vertex index that must lie in `1:n` type(error_t), intent(out), optional :: err logical :: ok !! `.true.` when the graph and vertex are usable integer(default_int) :: n ok = .false. if (.not. graph%is_valid(err)) return n = graph%n_rows() if (n /= graph%n_cols()) then call fail(err, "pic_graph: the adjacency matrix of a graph must be square") return end if if (n < 1) then call fail(err, "pic_graph: a graph must have at least one vertex") return end if if (int(n, int64) > int(huge(0_int32), int64)) then call fail(err, "pic_graph: vertex count exceeds the int32 payload of the priority queue") return end if if (source < 1 .or. source > n) then call fail(err, "pic_graph: vertex index is outside 1:n") return end if ok = .true. end function check_graph