Convert the graph to a dense representation.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(graph_type), | intent(inout) | :: | this |
Parent. Instance of the graph structure. |
module subroutine convert_to_dense(this) !! Convert the graph to a dense representation. implicit none ! Arguments class(graph_type), intent(inout) :: this !! Parent. Instance of the graph structure. ! Local variables integer :: v, e, i, j, idx !! Loop indices. if(.not.this%is_sparse) return this%is_sparse = .false. if(allocated(this%vertex_features)) deallocate(this%vertex_features) if(allocated(this%edge_features)) deallocate(this%edge_features) if(allocated(this%edge_weights)) deallocate(this%edge_weights) allocate(this%vertex(this%num_vertices)) allocate(this%edge(this%num_edges)) do v = 1, this%num_vertices idx = this%vertex(v)%id if(idx.eq.-1) idx = v this%vertex(v)%feature = this%vertex_features(:,idx) this%vertex(v)%id = v end do do e = 1, this%num_edges idx = this%edge(e)%id if(idx.eq.-1) idx = e this%edge(e)%feature = this%edge_features(:,idx) this%edge(e)%weight = this%edge_weights(idx) this%edge(e)%id = e end do if(allocated(this%adjacency)) deallocate(this%adjacency) allocate(this%adjacency(this%num_vertices, this%num_vertices)) this%adjacency = 0 do i = 1, size(this%adj_ia, dim=1)-1 do j = this%adj_ia(i), this%adj_ia(i+1)-1 this%adjacency(i,this%adj_ja(1,j)) = this%adj_ja(2,j) end do end do deallocate(this%vertex_features) deallocate(this%edge_features) deallocate(this%edge_weights) deallocate(this%adj_ia) deallocate(this%adj_ja) end subroutine convert_to_dense