[pgf-tikz] Creating directed graphs with edge labels

Eric Gorr ericgorr at gmail.com
Thu Mar 5 17:30:40 CET 2020


Thank you for the reply. It was helpful.

I am surprised that I cannot find any graph generating solution that will
take edge labels into account while positioning.

Are there any plans to add such a feature to this project?

On Wed, Mar 4, 2020 at 5:46 PM Henri Menke <henrimenke at gmail.com> wrote:

> You can draw a similar graph in TikZ as well, but there edge labels also do
> not take part in the positioning algorithm, so overlaps have to be avoided
> manually.
>
> \documentclass{article}
> \usepackage{tikz}
> \usetikzlibrary{graphs,graphdrawing,quotes}
> \usegdlibrary{layered}
> \begin{document}
> \begin{tikzpicture}
>     \graph[layered layout, sibling distance=3cm, level distance=3cm] {
>         A ->[loop,"a very long label"] A,
>         A ->[loop,min distance=4cm,"a very long label"] A,
>         A ->["a long label" sloped] B,
>         A ->["a long label" sloped] C,
>         A ->["a long label" sloped] D,
>     };
> \end{tikzpicture}
> \end{document}
>
> I don't know much about graphdrawing (I'm only the maintainer, not the
> implementer) but I think there are no algorithm that take the labels into
> accout.
>
> Cheers, Henri
>
> On 3/5/20 10:05 AM, Eric Gorr wrote:
> > I would like to create a directed graph with edge labels with the
> following
> > properties:
> >
> >    1. edge labels do not overlap with each other
> >    2. edge labels do not overlap edges
> >    3. edge labels are drawn along the edge.
> >
> > For example, I can use the following graphviz graph
> >
> > digraph G {    splines=line;    rankdir=LR;    A -> B [label="a long
> > label"];    A -> C [label="a long label"];    A -> A [label="a very
> > long label"];    A -> A [label="a very long label"];    A -> D
> > [label="a long label"];}
> >
> > to generate https://i.stack.imgur.com/34uVM.png
> >
> > However, it does not seem possible to obtain a graph with edge labels
> with
> > the three properties.
> >
> > Is creating a graph like this using PGF TIKZ possible? If so, any
> examples
> > for how to do so would be helpful.
> >
> > Thank you.
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://tug.org/pipermail/pgf-tikz/attachments/20200305/2b9082dc/attachment.html>


More information about the pgf-tikz mailing list.