Call for node distance as a variable in TikZ
AFAIK you cannot simply read off the value of /tikz/node distance
. However, in this great answer by @Jake there is a simple way to amend node distance
by a pgf key that you can use.
\documentclass[12pt, a4paper]{article}
\usepackage{tikz}
\usetikzlibrary{automata, positioning, arrows,calc}
\tikzset{node distance/.append code={
\pgfkeyssetvalue{/tikz/node distance value}{#1}
}}
\begin{document}
\begin{tikzpicture}[>=stealth',shorten >=0.5pt,auto,node
distance=2cm,semithick,on grid,
every state/.style={minimum size=20pt, fill=none,draw=black}]
\node[state,label=center:$a$,inner sep=0pt] (a) {};
\node[state,label=center:$b$] (b) at ($(a) + sqrt(4/3)*(0:\pgfkeysvalueof{/tikz/node distance value}) $) {};
\node[state,label=center:$c$] (c) at ($(a) + sqrt(4/3)*(-60:\pgfkeysvalueof{/tikz/node distance value})$) {};
\path[->] (a) edge node {$1$} (b)
(c) edge node[right] {$1$} (b)
(b) edge [loop right] node[above] {$0,1$} (b);
\path[shorten <=0.5pt,<->] (a) edge node[left]{$0$} (c);
\end{tikzpicture}
\end{document}
You can create a macro \def\nodedistance{1cm}
at the begining of the tikzpicture
. Later if needed this macro could be redefined .
\documentclass[12pt, a4paper]{article}
\usepackage{tikz}
\usetikzlibrary{automata, positioning, arrows,calc}
\begin{document}
\begin{tikzpicture}[>=stealth',shorten >=0.5pt,auto,semithick,on grid]
\def\nodedistance{1cm} % <------------
\tikzstyle{every state}=[minimum size=20pt, fill=none,draw=black]
\node[state,label=center:$a$,inner sep=0pt] (a) {};
\node[state,label=center:$b$] (b) at ($(a) + sqrt(1/3)*4*(0:\nodedistance) $) {};
\node[state,label=center:$c$] (c) at ($(a) + sqrt(1/3)*4*(-60:\nodedistance)$) {};
\path[->] (a) edge node {$1$} (b)
(c) edge node[right] {$1$} (b)
(b) edge [loop right] node[above] {$0,1$} (b);
\path[shorten <=0.5pt,<->] (a) edge node[left]{$0$} (c);
\end{tikzpicture}
\begin{tikzpicture}[>=stealth',shorten >=0.5pt,auto,semithick,on grid]
\def\nodedistance{2cm} % <----------------
\tikzstyle{every state}=[minimum size=20pt, fill=none,draw=black]
\node[state,label=center:$a$,inner sep=0pt] (a) {};
\node[state,label=center:$b$] (b) at ($(a) + sqrt(1/3)*4*(0:\nodedistance) $) {};
\node[state,label=center:$c$] (c) at ($(a) + sqrt(1/3)*4*(-60:\nodedistance)$) {};
\path[->] (a) edge node {$1$} (b)
(c) edge node[right] {$1$} (b)
(b) edge [loop right] node[above] {$0,1$} (b);
\path[shorten <=0.5pt,<->] (a) edge node[left]{$0$} (c);
\end{tikzpicture}
\end{document}