# Directory `graphics/pgf/contrib/adigraph`

# Adigraph

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.

It handles automatically the positioning of labels, with the exception of the horizontal position, and the inclinations of cuts.

**This library is released under MIT license (Copyright 2018 Luca Cappelletti)**.

## Documentation

For more information, you can read the documentation available here

## Basic setup

### Installing the package

If you are on Linux or macOs you can run the following.

sudo tlmgr install fp etoolbox adigraph

Otherwise install the packages with the package manager of your choice.

## Checking the version

All recent (1.3+) Adigraph versions offer the following command:

```
\AdigraphVersionNumber
```

If you get an `Undefined control sequence`

error you have a version previous to 1.3, you should consider updating it manually.

An approach could be the following:

- Download the latest version from ctan: here.
- Identify the position of the installed adigraph by running
`find / -type d -name adigraph`

. - Replace the old adigraph.sty with the new adigraph.sty downloaded from ctan.

### Requiring the package in the document

Remember to require the package in the document.

\usepackage{adigraph}

## Basic example

More examples and step by step explanation is available in the documentation.

Suppose you want to create a graph as the following, with an augmenting path highlighted and a couple of cuts:

We start by defining a new graph, called *myAdigraph*:

\NewAdigraph{myAdigraph}{ s:0,0; 1:2,2; 3:2,-2; 2:6,2; 4:6,-2; t:8,0; }{ s,1:25; s,3:25; 3,4:25; 1,2:35; 2,t:20; 4,t:30; 3,1:10; 4,2:10; 2,3:15::near start; 4,1:5::near start; }

At this point the output is the following:

\myAdigraph{}

Then we can add the augmenting path as follows:

\myAdigraph{ s,3,4,2,t:5; }

And the cuts (remember that the paths from previous steps are memorized by the library) are added as follows:

\myAdigraph{}{ 2,t,red; 3,4,blue; }

The result with the cuts is the following:

You can add both cuts and paths at the same time to keep the latest path highlighted:

\myAdigraph{ s,3,4,2,t:5; }{ 2,t,red; 3,4,blue; }

Have a nice day!

**Luca Cappelletti**

Download the contents of this package in one zip archive (562.7k).

## adigraph – Augmenting directed graphs

This LaTeX package provides the means to easily draw augmenting oriented graphs, as well as cuts on them, to demonstrate steps of algorithms for solving max-flow min-cut problems.

This package requires the other LaTeX packages fp, xparse, xstring, and TikZ (in particular the TikZ calc library).

Package | adigraph |

Bug tracker | https://github.com/LucaCappelletti94/adigraph/issues |

Repository | https://github.com/LucaCappelletti94/adigraph |

Version | 1.7.1 |

Licenses | MIT License |

Copyright | 2018 Luca Cappelletti |

Maintainer | Luca Cappelletti |

Contained in | TeX Live as adigraph MiKTeX as adigraph |

Topics | PGF TikZ Diagrams |