dag Derived Type

type, public :: dag

a directed acyclic graph (DAG)


Inherits

type~~dag~~InheritsGraph type~dag dag type~vertex vertex type~dag->type~vertex vertices

Components

Type Visibility Attributes Name Initial
integer, private :: n = 0

number of vertices

type(vertex), private, dimension(:), allocatable :: vertices

the vertices in the DAG.


Type-Bound Procedures

procedure, public :: set_vertices => dag_set_vertices

  • private subroutine dag_set_vertices(me, nvertices)

    set the number of vertices in the dag

    Arguments

    Type IntentOptional Attributes Name
    class(dag), intent(inout) :: me
    integer, intent(in) :: nvertices

    number of vertices

procedure, public :: set_edges => dag_set_edges

  • private subroutine dag_set_edges(me, ivertex, edges)

    set the edges for a vertex in a dag

    Arguments

    Type IntentOptional Attributes Name
    class(dag), intent(inout) :: me
    integer, intent(in) :: ivertex

    vertex number

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

procedure, public :: set_vertex_info => dag_set_vertex_info

  • private subroutine dag_set_vertex_info(me, ivertex, label, attributes)

    set info about a vertex in a dag.

    Arguments

    Type IntentOptional Attributes Name
    class(dag), intent(inout) :: me
    integer, intent(in) :: ivertex

    vertex number

    character(len=*), intent(in), optional :: label

    if a label is not set, then the integer vertex number is used.

    character(len=*), intent(in), optional :: attributes

    other attributes when saving as a diagraph.

procedure, public :: toposort => dag_toposort

  • private subroutine dag_toposort(me, order, istat)

    Main toposort routine

    Arguments

    Type IntentOptional Attributes Name
    class(dag), intent(inout) :: me
    integer, intent(out), dimension(:), allocatable :: order

    the toposort order

    integer, intent(out) :: istat

    Status flag:

    Read more…

procedure, public :: generate_digraph => dag_generate_digraph

  • private function dag_generate_digraph(me, rankdir, dpi) result(str)

    Generate a Graphviz digraph structure for the DAG.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(dag), intent(in) :: me
    character(len=*), intent(in), optional :: rankdir

    right to left orientation (e.g. 'RL')

    integer, intent(in), optional :: dpi

    resolution (e.g. 300)

    Return Value character(len=:), allocatable

procedure, public :: generate_dependency_matrix => dag_generate_dependency_matrix

  • private subroutine dag_generate_dependency_matrix(me, mat)

    Generate the dependency matrix for the DAG.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(dag), intent(in) :: me
    logical, intent(out), dimension(:,:), allocatable :: mat

    dependency matrix

procedure, public :: save_digraph => dag_save_digraph

  • private subroutine dag_save_digraph(me, filename, rankdir, dpi)

    Generate a Graphviz digraph structure for the DAG and write it to a file.

    Arguments

    Type IntentOptional Attributes Name
    class(dag), intent(in) :: me
    character(len=*), intent(in), optional :: filename

    file name for diagraph

    character(len=*), intent(in), optional :: rankdir

    right to left orientation (e.g. 'RL')

    integer, intent(in), optional :: dpi

    resolution (e.g. 300)

procedure, public :: get_edges => dag_get_edges

  • private pure function dag_get_edges(me, ivertex) result(edges)

    get the edges for the vertex (all the the vertices that this vertex depends on).

    Arguments

    Type IntentOptional Attributes Name
    class(dag), intent(in) :: me
    integer, intent(in) :: ivertex

    Return Value integer, dimension(:), allocatable

procedure, public :: get_dependencies => dag_get_dependencies

  • private pure function dag_get_dependencies(me, ivertex) result(dep)

    get all the vertices that depend on this vertex.

    Arguments

    Type IntentOptional Attributes Name
    class(dag), intent(in) :: me
    integer, intent(in) :: ivertex

    Return Value integer, dimension(:), allocatable

    the set of all vertices than depend on ivertex

procedure, public :: destroy => dag_destroy

  • private subroutine dag_destroy(me)

    Destroy the dag.

    Arguments

    Type IntentOptional Attributes Name
    class(dag), intent(inout) :: me

Source Code

    type,public :: dag
        !! a directed acyclic graph (DAG)
        private
        integer :: n = 0 !! number of `vertices`
        type(vertex),dimension(:),allocatable :: vertices  !! the vertices in the DAG.
    contains
        procedure,public :: set_vertices     => dag_set_vertices
        procedure,public :: set_edges        => dag_set_edges
        procedure,public :: set_vertex_info  => dag_set_vertex_info
        procedure,public :: toposort         => dag_toposort
        procedure,public :: generate_digraph => dag_generate_digraph
        procedure,public :: generate_dependency_matrix => dag_generate_dependency_matrix
        procedure,public :: save_digraph     => dag_save_digraph
        procedure,public :: get_edges        => dag_get_edges
        procedure,public :: get_dependencies => dag_get_dependencies
        procedure,public :: destroy          => dag_destroy
    end type dag