| 1 |
# Adigraph |
| 2 |
[Adigraph](https://ctan.org/pkg/adigraph) is a pure latex library for drawing directed graphs and augmenting directed graphs, and to draw cuts over them. It DOES NOT require external libraries such as Graphviz or DOT. |
| 3 |
|
| 4 |
It handles automatically the positioning of labels, with the exception of the horizontal position, and the inclinations of cuts. |
| 5 |
|
| 6 |
**This library is released under MIT license (Copyright 2018 Luca Cappelletti)**. |
| 7 |
|
| 8 |
## Documentation |
| 9 |
For more information, you can read the documentation available [here](https://github.com/LucaCappelletti94/adigraph/blob/master/adigraph_documentation.pdf) |
| 10 |
|
| 11 |
## Basic setup |
| 12 |
### Installing the package |
| 13 |
If you are on Linux or macOs you can run the following. |
| 14 |
```bash |
| 15 |
sudo tlmgr install fp etoolbox adigraph |
| 16 |
``` |
| 17 |
|
| 18 |
Otherwise install the packages with the package manager of your choice. |
| 19 |
|
| 20 |
## Checking the version |
| 21 |
All recent (1.3+) Adigraph versions offer the following command: |
| 22 |
|
| 23 |
```latex |
| 24 |
\AdigraphVersionNumber |
| 25 |
``` |
| 26 |
|
| 27 |
If you get an `Undefined control sequence` error you have a version previous to 1.3, you should consider updating it manually. |
| 28 |
|
| 29 |
An approach could be the following: |
| 30 |
|
| 31 |
1. Download the latest version from ctan: [here](https://ctan.org/pkg/adigraph). |
| 32 |
2. Identify the position of the installed adigraph by running `find / -type d -name adigraph`. |
| 33 |
3. Replace the old adigraph.sty with the new adigraph.sty downloaded from ctan. |
| 34 |
|
| 35 |
### Requiring the package in the document |
| 36 |
Remember to require the package in the document. |
| 37 |
|
| 38 |
```latex |
| 39 |
\usepackage{adigraph} |
| 40 |
``` |
| 41 |
|
| 42 |
## Basic example |
| 43 |
More examples and step by step explanation is available in the [documentation](https://github.com/LucaCappelletti94/adigraph/blob/master/adigraph_documentation.pdf). |
| 44 |
|
| 45 |
Suppose you want to create a graph as the following, with an augmenting path highlighted and a couple of cuts: |
| 46 |
|
| 47 |
 |
| 48 |
|
| 49 |
We start by defining a new graph, called *myAdigraph*: |
| 50 |
|
| 51 |
```latex |
| 52 |
\NewAdigraph{myAdigraph}{ |
| 53 |
s:0,0; |
| 54 |
1:2,2; |
| 55 |
3:2,-2; |
| 56 |
2:6,2; |
| 57 |
4:6,-2; |
| 58 |
t:8,0; |
| 59 |
}{ |
| 60 |
s,1:25; |
| 61 |
s,3:25; |
| 62 |
3,4:25; |
| 63 |
1,2:35; |
| 64 |
2,t:20; |
| 65 |
4,t:30; |
| 66 |
3,1:10; |
| 67 |
4,2:10; |
| 68 |
2,3:15::near start; |
| 69 |
4,1:5::near start; |
| 70 |
} |
| 71 |
``` |
| 72 |
|
| 73 |
At this point the output is the following: |
| 74 |
|
| 75 |
```latex |
| 76 |
\myAdigraph{} |
| 77 |
``` |
| 78 |
|
| 79 |
 |
| 80 |
|
| 81 |
Then we can add the augmenting path as follows: |
| 82 |
|
| 83 |
```latex |
| 84 |
\myAdigraph{ |
| 85 |
s,3,4,2,t:5; |
| 86 |
} |
| 87 |
``` |
| 88 |
|
| 89 |
 |
| 90 |
|
| 91 |
And the cuts (remember that the paths from previous steps are memorized by the library) are added as follows: |
| 92 |
|
| 93 |
```latex |
| 94 |
\myAdigraph{}{ |
| 95 |
2,t,red; |
| 96 |
3,4,blue; |
| 97 |
} |
| 98 |
``` |
| 99 |
|
| 100 |
The result with the cuts is the following: |
| 101 |
|
| 102 |
 |
| 103 |
|
| 104 |
You can add both cuts and paths at the same time to keep the latest path highlighted: |
| 105 |
|
| 106 |
```latex |
| 107 |
\myAdigraph{ |
| 108 |
s,3,4,2,t:5; |
| 109 |
}{ |
| 110 |
2,t,red; |
| 111 |
3,4,blue; |
| 112 |
} |
| 113 |
``` |
| 114 |
|
| 115 |
 |
| 116 |
|
| 117 |
Have a nice day! |
| 118 |
|
| 119 |
**Luca Cappelletti** |