# Change distance between nodes in tikz graph

I am attempting to do this, but I cannot seem to find the correct syntax for it in LaTeX.

Here is what I have:

\documentclass[12pt]{article}
\usepackage[english]{babel}
\usepackage{tikz}

\usetikzlibrary{graphdrawing}
\usetikzlibrary{positioning,graphs}
\usegdlibrary{layered}
\begin{document}
\begin{tikzpicture}[baseline]
\begin{graph}[layered layout,nodes={draw,circle, node distance=10cm}]
{1->[edge label=bob, node distance=3cm]2};
\end{graph}
\end{tikzpicture}
\end{document}


None of the node distance commands seem to have an impact

Any ideas?

-

## 1 Answer

The layered layout ignores node distance; however, you can use level sep (and possibly sibling sep if necessary):

\documentclass[12pt]{article}
\usepackage[english]{babel}
\usepackage{tikz}
\usetikzlibrary{graphdrawing}
\usetikzlibrary{positioning,graphs}
\usegdlibrary{layered}

\begin{document}
\begin{tikzpicture}[baseline]
\begin{graph}[layered layout,nodes={draw,circle},level sep=2cm]
{1->[edge label=bob]2};
\end{graph}
\end{tikzpicture}
\end{document}


-
So a combination of level sep and sibling sep will force it to be that distance at least between nodes? – soandos Feb 9 '14 at 3:58
As an aside, how can I represent a self loop on one of these nodes? – soandos Feb 9 '14 at 4:01
@soandos those values will set the distance between the center of the nodes from one level to the nodes on the next level (level sep) and between siblings (sibling sep); but, in fact, it is weird that node distance is having no effect. – Gonzalo Medina Feb 9 '14 at 4:08
@soandos for the loop, question, an example: \begin{tikzpicture}[baseline] \begin{graph}[layered layout,nodes={draw,circle}] {1->[edge label=bob]2->[loop right]2}; \end{graph} \end{tikzpicture} – Gonzalo Medina Feb 9 '14 at 4:09
So the fact that node distance is not having an affect is a bug? – soandos Feb 9 '14 at 4:11