get_neighbors_csr Subroutine

private subroutine get_neighbors_csr(self, node_id, neighbors)

Type Bound

type_node_adjacency

Arguments

Type IntentOptional Attributes Name
class(type_node_adjacency), intent(in) :: self
integer(kind=int32), intent(in) :: node_id
integer(kind=int32), intent(out), allocatable :: neighbors(:)

Called by

proc~~get_neighbors_csr~~CalledByGraph proc~get_neighbors_csr type_node_adjacency%get_neighbors_csr proc~sort_and_enqueue_neighbors sort_and_enqueue_neighbors proc~sort_and_enqueue_neighbors->proc~get_neighbors_csr proc~execute_bfs_ordering execute_bfs_ordering proc~execute_bfs_ordering->proc~sort_and_enqueue_neighbors proc~execute_reordering_core execute_reordering_core proc~execute_reordering_core->proc~execute_bfs_ordering proc~cm_reorder_method cm_reorder_method proc~cm_reorder_method->proc~execute_reordering_core proc~rcm_reorder_method rcm_reorder_method proc~rcm_reorder_method->proc~execute_reordering_core interface~cm_reorder_method type_reordering%cm_reorder_method interface~cm_reorder_method->proc~cm_reorder_method interface~rcm_reorder_method type_reordering%rcm_reorder_method interface~rcm_reorder_method->proc~rcm_reorder_method proc~initialize_type_reordering type_reordering%initialize_type_reordering proc~initialize_type_reordering->interface~cm_reorder_method proc~initialize_type_reordering->interface~rcm_reorder_method

Source Code

    subroutine get_neighbors_csr(self, node_id, neighbors)
        implicit none
        class(type_node_adjacency), intent(in) :: self
        integer(int32), intent(in) :: node_id
        integer(int32), allocatable, intent(out) :: neighbors(:)
        integer(int32) :: start_p, end_p, degree

        if (node_id < 1 .or. node_id > self%num_nodes) then
            allocate (neighbors(0)); return
        end if
        start_p = self%ptr(node_id)
        end_p = self%ptr(node_id + 1) - 1
        degree = end_p - start_p + 1
        if (degree <= 0) then
            allocate (neighbors(0)); return
        end if
        allocate (neighbors(degree))
        neighbors = self%ind(start_p:end_p)
    end subroutine get_neighbors_csr