README1 5.5 KB

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