## ㄟ(≧◇≦)ㄏ

## About

This is a single file directed graph layout library in C and javascript with extra graph features  
  
- Multiple graphs at once  
- Subgraph support in a graph  
- Folding of subgraphs in a graph  
- Layout and re-layout  
- Superbubbles algorithm to automatic find subparts of the graph  
  
<details>

- [About](#about)
- [Install](#install)
- [Usage](#usage)
  - [API](#api)
- [Usage examples](#usage-examples)
- [Goals](#goals)
- [Javascript](#javascript)
- [Notes](#notes)
- [License](#license)

</details>

## Install

make

## Usage

The user program must supply nodes with the needed (x,y) size of the node with the label text.  
The user program must supply edges between the nodes with optional size (x,y) for edge label text.  
After layout the data of the drawing is available using routines and the user program can draw a image or gui window.  

### Api

The api is in d4dag.h

## Usage-examples

Embedded in qvge this creates layout and qvge does the drawing and qt5 gui controls.

## Goals
  
The only way for secure programming is simplified C and using parts of misra, nasa and other guides  
The use of the unloop tool will result in a very much simplified ast with only if and goto statements  
Maybe then the amount of actually used code in the compiler is much smaller resulting in less trouble  
At least with gcc there is difference in number of compiler building blocks to be studied more  
This is not mission-critial software but attempts are made to follow some guides  
https://github.com/abougouffa/awesome-coding-standards  
https://en.wikipedia.org/wiki/The_Power_of_10:_Rules_for_Developing_Safety-Critical_Code  
* Avoid complex flow constructs, such as goto and recursion.  
* All loops must have fixed bounds. This prevents runaway code.  
* Avoid heap memory allocation.  
* Restrict functions to a single printed page.  
* Use a minimum of two runtime assertions per function.  
* Restrict the scope of data to the smallest possible.  
* Check the return value of all non-void functions, or cast to void to indicate the return value is useless.  
* Use the preprocessor sparingly.  
* Limit pointer use to a single dereference, and do not use function pointers.  
* Compile with all possible warnings active; all warnings should then be addressed before release of the software.  
And much more is possible.  
  
This is a guide for gcc clang compilers from airbus aerospace https://github.com/airbus-seclab/c-compiler-security  
Also the Free rosechecker project on sourceforge has a tool for cert standards  
There are more Free tools as Linux kernel sparse source checker and others available to use  
This source is not sabotaged because of wrongdoing politics as some other GPL Free projects do  
This source has no linkage to other libs to make it easy for embedded devices or wasm web assembly  
The d4dag.c graph layout routines can be compiled to webassebly using emscripten  
The d4dag.c graph layout routines can be compiled to llvm bytecode to lisp to java bytecode to javascript  
The d4dag.c graph layout routines can be compiled to llvm bytecode to javascript assembly to java bytecode to javascript  
The d4dag.c source is created to be usable for internet of things iot and embedded applications  
The fedora Linux has a internet of things edition maintained and tested with the extra tools needed  
The simplec.l is a bug fixed version of cunloop in cutils-1.6 which has bugs  
  
## Javascript
Because there is no good usable GNU GPL Free javascript directed graph layout  
creating something in d4dag.js and d4dag.html doing a sugiyama graph layout  
  
## Notes
The d4dag.wat file has some generated wasm web assembly  
The wandbox.org site has a browser page to paste C source and test the output with many gcc and clang compiler versions  
The OverCG.py script generates callgraph from llvm ir ll textual data files  
The sparse-llvm compiler is used to generate llvm bitcode  
The smatch source checker from sourceforge is used to check  
The sourceforge smatch repo is not maintained but the updated version as at https://repo.or.cz/w/smatch.git  
There is support for Intel icc compiler which has extra features  
  
## License
  
This is GNU GPL Version 3+ Free Software  
  
This is the compact callgraph of d4dag.c  
![callgraph](gml4gtk-gcc-splay-tree-summary-callgraph.png)  
  
SPDX-License-Identifier: GPL-3.0+   
License-Filename: LICENSE  
  
![gplv3](gplv3.png)  
  
Made in <span>🇳🇱</span>  
  
