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. |
not very useful for now, since all vertex attributes are private
Get the i
th vertex.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(dag), | intent(inout) | :: | me | |||
integer(kind=ip), | intent(in) | :: | i |
vertex number |
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 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 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 |
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
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 |
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 |
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 |
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 |
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 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) |
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) |
Destroy the dag
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(dag), | intent(inout) | :: | me |
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)
private routine to initialize some internal variables
Initialize the internal private variables used for graph traversal.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(dag), | intent(inout) | :: | me |
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 |
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 |
type,public :: dag !! a directed acyclic graph (DAG). !! a collection of vertices (nodes) that are connected to other vertices. private integer(ip) :: n = 0 !! number of vertices (size of `vertices` array) type(vertex),dimension(:),allocatable :: vertices !! the vertices in the DAG. The index in !! this array if the vertex number. contains private 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 :: init_internal_vars !! private routine to initialize some internal variables procedure :: dag_set_edges_no_atts, dag_set_edges_vector_atts end type dag