set the number of vertices (nodes) in the dag.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(dag), | intent(inout) | :: | me | |||
integer(kind=ip), | intent(in) | :: | nvertices |
number of vertices |
||
character(len=*), | intent(in), | optional, | dimension(nvertices) | :: | labels |
vertex name strings |
character(len=*), | intent(in), | optional | :: | attributes |
other attributes when saving as a diagraph. |
|
class(*), | intent(in), | optional | :: | metadata |
optional user-defined metadata |
subroutine dag_set_vertices(me,nvertices,labels,attributes,metadata) class(dag),intent(inout) :: me integer(ip),intent(in) :: nvertices !! number of vertices character(len=*),dimension(nvertices),intent(in),optional :: labels !! vertex name strings character(len=*),intent(in),optional :: attributes !! other attributes when !! saving as a diagraph. class(*),intent(in),optional :: metadata !! optional user-defined metadata integer(ip) :: i !! counter logical :: has_label !! if `labels` is specified character(len=:),allocatable :: label_ !! temp variable for labels if (nvertices<=0) error stop 'error: nvertices must be >= 1' if (allocated(me%vertices)) deallocate(me%vertices) me%n = nvertices allocate(me%vertices(nvertices)) me%vertices%ivertex = [(i,i=1,nvertices)] ! vertex indices has_label = present(labels) do i = 1, nvertices if (has_label) then label_ = trim(adjustl(labels(i))) else label_ = integer_to_string(i) ! just use the vertex number end if call me%set_vertex_info(ivertex=i,label=label_,& attributes=attributes,metadata=metadata) end do end subroutine dag_set_vertices