DAG Module.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | public, | parameter | :: | daglib_ip | = | int32 |
Integer working precision if not specified [4 bytes] |
| integer, | private, | parameter | :: | ip | = | daglib_ip |
local copy of |
| integer(kind=ip), | private, | parameter | :: | MAX_INT_STR_LEN | = | 64 |
maximum length of an integer string |
constructor for an edge type.
Constructor for edge type.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=ip), | intent(in), | optional | :: | ivertex |
vertex number defining the destination of this edge |
|
| character(len=*), | intent(in), | optional | :: | label |
vertex name for grahviz |
|
| character(len=*), | intent(in), | optional | :: | attributes |
other attributes for graphviz |
|
| class(*), | intent(in), | optional | :: | metadata |
optional user-defined metadata |
user-provided function for traversing a dag.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=ip), | intent(in) | :: | ivertex |
vertex number |
||
| logical, | intent(out) | :: | stop |
set to true to stop the process |
||
| integer(kind=ip), | intent(in), | optional | :: | iedge |
edge index for this vertex (note: not the vertex number, the index in the array of edge vertices) [not present if this is the starting node] |
the "to" vertex that defines an edge. This is part of the array of vertices contained without the "from" vertex type. an edge can also have optional attrubutes for graphviz.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer(kind=ip), | public | :: | ivertex | = | 0 |
vertex number (the index in the dag |
|
| character(len=:), | public, | allocatable | :: | label |
used for diagraph |
||
| character(len=:), | public, | allocatable | :: | attributes |
used for diagraph |
||
| class(*), | public, | allocatable | :: | metadata |
user-defined metadata |
constructor for an edge type.
| private impure, elemental function edge_constructor (ivertex, label, attributes, metadata) | Constructor for edge type. |
a vertex (or node) of a directed acyclic graph (DAG)
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| type(edge), | private, | dimension(:), allocatable | :: | edges |
these are the vertices that this vertex depends on. (edges of the graph). |
||
| integer(kind=ip), | private | :: | ivertex | = | 0 |
vertex number (the index in the dag |
|
| logical, | private | :: | checking | = | .false. |
used for toposort |
|
| logical, | private | :: | marked | = | .false. |
used for toposort |
|
| character(len=:), | private, | allocatable | :: | label |
used for diagraph |
||
| character(len=:), | private, | allocatable | :: | attributes |
used for diagraph |
||
| class(*), | private, | allocatable | :: | metadata |
user-defined metadata |
| generic, private :: set_edges => set_edge_vector_vector, add_edge | |
| procedure, private :: add_edge | |
| procedure, private :: set_edge_vector_vector | |
| procedure, private :: remove_edge |
a directed acyclic graph (DAG). a collection of vertices (nodes) that are connected to other vertices.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer(kind=ip), | private | :: | n | = | 0 |
number of vertices (size of |
|
| type(vertex), | private, | dimension(:), allocatable | :: | vertices |
the vertices in the DAG. The index in this array if the vertex number. |
| procedure, public :: vertex => dag_get_vertex | ../../ not very useful for now, since all vertex attributes are private |
| procedure, public :: number_of_vertices => dag_get_number_of_vertices | |
| procedure, public :: get_edge_metadata => dag_get_edge_metadata | |
| procedure, public :: get_vertex_metadata => dag_get_vertex_metadata | |
| procedure, public :: get_edges => dag_get_edges | |
| procedure, public :: get_dependencies => dag_get_dependencies | |
| procedure, public :: set_vertices => dag_set_vertices | |
| procedure, public :: set_vertex_info => dag_set_vertex_info | |
| procedure, public :: add_edge => dag_add_edge | |
| generic, public :: set_edges => dag_set_edges_no_atts, dag_set_edges_vector_atts | |
| procedure, public :: remove_edge => dag_remove_edge | |
| procedure, public :: remove_vertex => dag_remove_node | |
| procedure, public :: toposort => dag_toposort | |
| procedure, public :: traverse => dag_traverse | |
| 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 :: destroy => dag_destroy | |
| procedure, public :: get_edge_index | |
| procedure, private :: init_internal_vars | ../../ private routine to initialize some internal variables |
| procedure, private :: dag_set_edges_vector_atts | |
| procedure, private :: dag_set_edges_no_atts |
Constructor for edge type.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=ip), | intent(in), | optional | :: | ivertex |
vertex number defining the destination of this edge |
|
| character(len=*), | intent(in), | optional | :: | label |
vertex name for grahviz |
|
| character(len=*), | intent(in), | optional | :: | attributes |
other attributes for graphviz |
|
| class(*), | intent(in), | optional | :: | metadata |
optional user-defined metadata |
get the edges for the vertex (all of the vertices that this vertex depends on).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(dag), | intent(in) | :: | me | |||
| integer(kind=ip), | intent(in) | :: | ivertex |
get all the vertices that depend on this vertex.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(dag), | intent(in) | :: | me | |||
| integer(kind=ip), | intent(in) | :: | ivertex |
the set of all vertices
than depend on ivertex
Returns the number of vertices (nodes) in the dag.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(dag), | intent(in) | :: | me |
number of vertices
Returns the metadata for a vertex (node) in the dag.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(dag), | intent(in) | :: | me | |||
| integer(kind=ip), | intent(in) | :: | ivertex |
vertex number |
Returns the metadata for an edge in the dag.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(dag), | intent(in) | :: | me | |||
| integer(kind=ip), | intent(in) | :: | ivertex |
vertex number |
||
| integer(kind=ip), | intent(in) | :: | iedge |
edge vertex |
Returns the index in the edge array of the vertex.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(dag), | intent(in) | :: | me | |||
| integer(kind=ip), | intent(in) | :: | ivertex |
vertex number |
||
| integer(kind=ip), | intent(in) | :: | iedge |
edge vertex number |
the index of the iedge vertex in
the edge array (0 if not found)
Get the ith vertex.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(dag), | intent(inout) | :: | me | |||
| integer(kind=ip), | intent(in) | :: | i |
vertex number |
Generate a Graphviz digraph structure for the DAG.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(dag), | intent(in) | :: | me | |||
| character(len=*), | intent(in), | optional | :: | rankdir |
right to left orientation (e.g. 'RL') |
|
| integer(kind=ip), | intent(in), | optional | :: | dpi |
resolution (e.g. 300) |
Integer to allocatable string.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=ip), | intent(in) | :: | i |
specify the edge indices for this vertex
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vertex), | intent(inout) | :: | me | |||
| integer(kind=ip), | intent(in), | dimension(:) | :: | edges | ||
| character(len=*), | intent(in), | optional, | dimension(:) | :: | label | |
| character(len=*), | intent(in), | optional, | dimension(:) | :: | attributes |
other attributes when saving as a diagraph. |
| class(*), | intent(in), | optional | :: | metadata |
optional user-defined metadata |
add an edge index for this vertex
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vertex), | intent(inout) | :: | me | |||
| integer(kind=ip), | intent(in) | :: | e | |||
| character(len=*), | intent(in), | optional | :: | label | ||
| character(len=*), | intent(in), | optional | :: | attributes |
other attributes when saving as a diagraph. |
|
| class(*), | intent(in), | optional | :: | metadata |
optional user-defined metadata |
remove an edge index from this vertex
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(vertex), | intent(inout) | :: | me | |||
| integer(kind=ip), | intent(in) | :: | e |
Remove a node from a dag. Will also remove any edges connected to it.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(dag), | intent(inout) | :: | me | |||
| integer(kind=ip), | intent(in) | :: | ivertex |
the node to remove |
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 |
set info about a vertex in a dag.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(dag), | intent(inout) | :: | me | |||
| integer(kind=ip), | 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. |
|
| class(*), | intent(in), | optional | :: | metadata |
optional user-defined metadata |
Add an edge to a dag.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(dag), | intent(inout) | :: | me | |||
| integer(kind=ip), | intent(in) | :: | ivertex |
vertex number |
||
| integer(kind=ip), | intent(in) | :: | iedge |
the vertex to connect to |
||
| character(len=*), | intent(in), | optional | :: | label |
edge label |
|
| character(len=*), | intent(in), | optional | :: | attributes |
other attributes when saving as a diagraph. |
|
| class(*), | intent(in), | optional | :: | metadata |
optional user-defined metadata |
set the edges for a vertex in a dag
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(dag), | intent(inout) | :: | me | |||
| integer(kind=ip), | intent(in) | :: | ivertex |
vertex number |
||
| integer(kind=ip), | intent(in), | dimension(:) | :: | edges |
Remove an edge from a dag.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(dag), | intent(inout) | :: | me | |||
| integer(kind=ip), | intent(in) | :: | ivertex |
vertex number |
||
| integer(kind=ip), | intent(in) | :: | iedge |
the edge to remove |
set the edges for a vertex in a dag
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(dag), | intent(inout) | :: | me | |||
| integer(kind=ip), | intent(in) | :: | ivertex |
vertex number |
||
| integer(kind=ip), | intent(in), | dimension(:) | :: | edges | ||
| character(len=*), | intent(in), | dimension(:) | :: | attributes |
other attributes when saving as a diagraph. |
|
| character(len=*), | intent(in), | optional, | dimension(:) | :: | label |
Initialize the internal private variables used for graph traversal.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(dag), | intent(inout) | :: | me |
Main toposort routine
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(dag), | intent(inout) | :: | me | |||
| integer(kind=ip), | intent(out), | dimension(:), allocatable | :: | order |
the toposort order |
|
| integer(kind=ip), | intent(out) | :: | istat |
Status flag: |
depth-first graph traversal of the dag.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(dag), | intent(inout) | :: | me | |||
| integer(kind=ip), | intent(in) | :: | ivertex |
the vertex number to start on |
||
| procedure(traverse_func) | :: | userfunc |
a user-provided function that will be called for each vertex/edge combination |
Generate the dependency matrix for the DAG.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(dag), | intent(in) | :: | me | |||
| logical, | intent(out), | dimension(:,:), allocatable | :: | mat |
dependency matrix |
Generate a Graphviz digraph structure for the DAG and write it to a file.
| Type | Intent | Optional | 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(kind=ip), | intent(in), | optional | :: | dpi |
resolution (e.g. 300) |