README1 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. This is a single file graph layout library in c
  2. which can be compiled-in or used as .a/.so library
  3. The api programming interface is detailed in sfg.h
  4. The only clib functions needed are calloc() and free()
  5. The example program is sfgdemo.c and program ./sfgdemo
  6. See also the wasm directory running sfg.c in the browser
  7. To make the demo program sfgdemo type make
  8. To cleanup use make clean
  9. To indent the source use make indent
  10. To check for memory leaks use make valgrind
  11. To make libsfg.a library use make sfga
  12. To make libsfg.so library use make sfgaso
  13. To make javascript version use make emcc
  14. To make python module with swig use make swigpython
  15. To make perl module with swig use make swigperl
  16. To make c++ with swig use make swigcplus
  17. To make go with swig use make swiggo
  18. To make java with swig use make swigjava
  19. Also javascript, php, modula3 and more interfacing
  20. to sfg.c can be generated with swig software
  21. Using llvm compiler run scan-build-8 make
  22. All routines in sfg.c return (int) 0 at oke status.
  23. First all nodes must be added and then the edges.
  24. For node or edge label a size of a rectangle to fit
  25. the label text can be specified in (tx,ty) parameter.
  26. Self-edges are allowed but not with a edgelabel.
  27. After sfg_layout() the node and edge data can be
  28. retrieved using a callback routine.
  29. Also other data can be retrieved using sfg() routines
  30. described in sfg.h
  31. At error all routines return a < 0 negative value and
  32. the meaning is described in sfg.h
  33. The sfg.c routines only uses calloc() and free() from
  34. the c-lib and nothing more than that.
  35. The sfg.c does calculate node and edge positions but
  36. has not a graph language parser or draw routines
  37. which must be created by the user.
  38. The sfg.c is usable for embedded software but it may
  39. have high cpu+memory usage. sfg.c size is 120 Kb
  40. The java version is in sfg.java size 336 Kb
  41. There is a java dot language parser at http://www.alexander-merz.com/graphviz/
  42. Using sfgdemo the sfgdemo.txt file is a graph which
  43. can be edited and data directory has some more data.
  44. Usage:
  45. ./sfgdemo
  46. ./sfgdemo input.txt output.svg
  47. It compiles to javascript using emscripten emcc
  48. When using swig software is can generate python interface
  49. with make swigpython and specify include directory
  50. Then tested with python-2.7:
  51. python
  52. >>> import sfg
  53. >>> sfg.sfg_version()
  54. 10
  55. >>>
  56. When using swig software is can generate perl interface
  57. with make swigperl
  58. The use:
  59. perl
  60. use sfg;
  61. print sfg::sfg_version(),"\n";
  62. <ctrl-d>
  63. 10
  64. There is a perl graphviz dot parser at https://metacpan.org/source/RSAVAGE/GraphViz2-Marpa-2.10
  65. When using swig software is can generate tcl interface
  66. with make swigtcl and specify include directory
  67. Then tested:
  68. tclsh
  69. % load ./sfg.so sfg
  70. % sfg_version
  71. 10
  72. %
  73. <ctrl-D>
  74. Also javascript, php, modula3 and more interfacing
  75. to sfg.c can be generated with swig software
  76. http://www.swig.org/Doc3.0/Contents.html#Contents
  77. Because this single-file library is a mini version of gml4gtk
  78. it is possible to use gml4gtk and take a look at it's source.
  79. In the java directory is the Java source and a jar file
  80. To run the Java version of sfg use: java -jar sfg.jar
  81. For php the ffi functions can be used with a sfg.so file
  82. or it can be done using swig wrappers.
  83. Because the sfg library can give the results of the relative
  84. (x,y) coordinates of a node it is possible to create own
  85. different way for absolyte (x,y) placement of the nodes.
  86. The graphviz dot tool cannot do this.
  87. /*
  88. * Copyright t lefering
  89. * parts are (C) Universitaet Passau 1986-1991
  90. * parts are Copyright (C) 1998-2021 Free Software Foundation, Inc.
  91. * parts are Copyright (C) Felix von Leitner from dietlibc
  92. *
  93. * https://notabug.org/mooigraph/sfgraph
  94. *
  95. * This program is free software: you can redistribute it and/or modify
  96. * it under the terms of the GNU General Public License as published by
  97. * the Free Software Foundation, either version 3 of the License, or
  98. * (at your option) any later version.
  99. *
  100. * This program is distributed in the hope that it will be useful,
  101. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  102. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  103. * GNU General Public License for more details.
  104. *
  105. * You should have received a copy of the GNU General Public License
  106. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  107. *
  108. * These are the four essential freedoms with GNU GPL software:
  109. * 1: freedom to run the program, for any purpose
  110. * 2: freedom to study how the program works, and change it to make it do what you wish
  111. * 3: freedom to redistribute copies to help your Free Software friends
  112. * 4: freedom to distribute copies of your modified versions to your Free Software friends
  113. * , ,
  114. * / \
  115. * ((__-^^-,-^^-__))
  116. * `-_---' `---_-'
  117. * `--|o` 'o|--'
  118. * \ ` /
  119. * ): :(
  120. * :o_o:
  121. * "-"
  122. *
  123. * SPDX-License-Identifier: GPL-3.0+
  124. * License-Filename: LICENSE
  125. */
  126. See also gml4gtk graph viewer on sourceforge.net, email is mooigraph on gmail.com
  127. /* end */