项目作者: jacobwilliams

项目描述 :
Directed Acyclic Graphs With Modern Fortran
高级语言: Fortran
项目地址: git://github.com/jacobwilliams/daglib.git
创建时间: 2018-01-17T16:43:53Z
项目社区:https://github.com/jacobwilliams/daglib

开源协议:Other

下载


" class="reference-link">daglib

Overview

Language
Build Status
GitHub release

DAGLIB is a modern Fortran module for creating and manipulating directed acyclic graphs (DAGs). It includes a toposort feature, and also the ability to generate files in the GraphViz “dot” notation.

Building

A Fortran Package Manager manifest file is included, so that the library and tests cases can be compiled with FPM. For example:

  1. fpm build --profile release
  2. fpm test --profile release

By default, the library is built with single precision (int32) integer values. Explicitly specifying the integer kind can be done using the following processor flag:

Preprocessor flag Kind Number of bytes
INT8 integer(kind=int8) 1
INT16 integer(kind=int16) 2
INT32 integer(kind=int32) 4
INT64 integer(kind=int64) 8

For example, to build a long integer version of the library:

  1. fpm build --profile release --flag "-DINT64"

Example

A simple example is shown below:

  1. program dag_example
  2. use dag_module
  3. implicit none
  4. type(dag) :: d
  5. integer,dimension(:),allocatable :: order
  6. integer :: istat
  7. integer :: i
  8. integer,parameter :: n_nodes = 6
  9. character(len=*),parameter :: filetype = 'pdf'
  10. ! create a dag:
  11. call d%set_vertices(n_nodes)
  12. call d%set_edges(2,[1]) ! 2 depends on 1
  13. call d%set_edges(3,[5,1]) ! 3 depends on 5 and 1
  14. call d%set_edges(4,[5]) ! 4 depends on 5
  15. call d%set_edges(5,[2]) ! 5 depends on 2
  16. call d%set_edges(6,[2,4]) ! 6 depends on 2 and 4
  17. ! toposort:
  18. call d%toposort(order,istat)
  19. ! define some styles for the GraphViz output:
  20. do i = 1, n_nodes
  21. if (i==3 .or. i==6) then
  22. call d%set_vertex_info(i,attributes='shape=square,fillcolor="SlateGray1",style=filled')
  23. else
  24. call d%set_vertex_info(i,attributes='shape=circle,fillcolor="cornsilk",style=filled')
  25. end if
  26. end do
  27. ! generate the GraphViz output:
  28. call d%save_digraph('test.dot','RL',300)
  29. call d%destroy()
  30. call execute_command_line('dot -Tpdf -o test.pdf test.dot')
  31. end program dag_example

This program produces the toposort order:

  1. order = [1, 2, 5, 3, 4, 6]

and the image file:

dag_example

Documentation

  • The API documentation for the current master branch can be found here. This is generated by processing the source files with FORD.

License

This library is released under a BSD-3 license.

See also

  • dag (a fork of this project)