Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=int32), | intent(out) | :: | current_saturation | |||
integer(kind=int32), | intent(in) | :: | node_id | |||
type(type_crs_adjacency_element), | intent(in) | :: | graph | |||
type(type_coloring), | intent(in) | :: | coloring |
subroutine update_saturation(current_saturation, node_id, graph, coloring) integer(int32), intent(out) :: current_saturation integer(int32), intent(in) :: node_id type(type_crs_adjacency_element), intent(in) :: graph type(type_coloring), intent(in) :: coloring integer(int32), allocatable :: neighbors(:) integer(int32), allocatable :: distinct_colors(:) integer(int32) :: i, j, num_distinct logical :: found neighbors = graph%get_neighbors(node_id) if (size(neighbors) == 0) then current_saturation = 0 call deallocate_array(neighbors) return end if allocate (distinct_colors(size(neighbors))) num_distinct = 0 do i = 1, size(neighbors) if (coloring%color(neighbors(i)) /= 0) then found = .false. do j = 1, num_distinct if (coloring%color(neighbors(i)) == distinct_colors(j)) then found = .true. exit end if end do if (.not. found) then num_distinct = num_distinct + 1 distinct_colors(num_distinct) = coloring%color(neighbors(i)) end if end if end do current_saturation = num_distinct call deallocate_array(neighbors) call deallocate_array(distinct_colors) end subroutine update_saturation