Set the number of edges of the graph.
This will deallocate the existing edges and set the number of edges. New edges will be allocated but not initialised.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(graph_type), | intent(inout) | :: | this |
Parent. Instance of the graph structure. |
||
| integer, | intent(in) | :: | num_edges |
Number of edges in the graph. |
||
| integer, | intent(in), | optional | :: | num_edge_features |
Number of edge features. |
module subroutine set_num_edges(this, num_edges, num_edge_features) !! Set the number of edges of the graph. !! !! This will deallocate the existing edges and set the number of edges. !! New edges will be allocated but not initialised. implicit none ! Arguments class(graph_type), intent(inout) :: this !! Parent. Instance of the graph structure. integer, intent(in) :: num_edges !! Number of edges in the graph. integer, intent(in), optional :: num_edge_features !! Number of edge features. ! Deallocate existing data if(allocated(this%edge)) deallocate(this%edge) if(allocated(this%adj_ia)) deallocate(this%adj_ia) if(allocated(this%adj_ja)) deallocate(this%adj_ja) if(allocated(this%adjacency)) deallocate(this%adjacency) ! Set new dimensions this%num_edges = num_edges if(present(num_edge_features)) this%num_edge_features = num_edge_features ! Allocate appropriate storage if(this%is_sparse)then allocate(this%edge_features(this%num_edge_features, this%num_edges)) allocate(this%edge_weights(this%num_edges)) else allocate(this%edge(num_edges)) end if end subroutine set_num_edges