set_edges Module Subroutine

module subroutine set_edges(this, vertex_index, connected_indices)

Add edge connections between vertices of the graph.

Arguments

Type IntentOptional Attributes Name
class(graph_type), intent(inout) :: this

Parent. Instance of the graph structure.

integer, intent(in) :: vertex_index

Index of the vertex.

integer, intent(in), dimension(:) :: connected_indices

Indices of the connected vertices.


Source Code

  module subroutine set_edges(this, vertex_index, connected_indices)
    !! Add edge connections between vertices of the graph.
    implicit none
    class(graph_type), intent(inout) :: this
    !! Parent. Instance of the graph structure.
    integer, intent(in) :: vertex_index
    !! Index of the vertex.
    integer, dimension(:), intent(in) :: connected_indices
    !! Indices of the connected vertices.

    ! Local variables
    integer :: i
    !! Loop index.
    logical :: directed
    !! Boolean whether the edge is directed.


    do i = 1, size(connected_indices)
       directed = (connected_indices(i) .lt. 0)
       call this%add_edge(index=[vertex_index, connected_indices(i)], &
                          directed=directed)
    end do
  end subroutine set_edges