add tag
topnush
I have this graph

```
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\begin{document}

\begin{frame}
\frametitle{Demonstration}
\begin{tikzpicture}
\begin{scope}[every node/.style={fill=blue, circle,thick,draw, minimum size=1.3cm}]
    \node[label={[xshift=0em, yshift=-1em]  $\infty$}]  (A) at (0,5) {A};
    \node[label={[xshift=0em, yshift=-1em] $\infty$}] (B) at (5,5) {B};
    \node[label={[xshift=0em, yshift=-1em] $\infty$}] (C) at (10,5) {C};
    \node[label={[xshift=-1em, yshift=-6em]  $\infty$}] (D) at (0,0) {D};
    \node[label={[xshift=-1em, yshift=-6em] $\infty$}] (E) at (5,0) {E};
    \node[label={[xshift=-1em, yshift=-6em]  $\infty$}] (F) at (10,0) {F} ;
\end{scope}

\begin{scope}[>={Stealth[black]},
              every node/.style={fill=white,circle},
              every edge/.style={draw=red,very thick}]
    \path [-] (A) edge node {$1$} (B);
    \path [-] (D) edge node {$2$} (B);
    \path [-] (A) edge node {$3$} (D);
    \path [-] (D) edge node {$3$} (E);
    \path [-] (E) edge node {$2$} (F);
    \path [-] (E) edge node {$6$} (B);
    \path [-] (E) edge node {$4$} (C);
    \path [-] (B) edge node {$3$} (C);
    \path [-] (B) edge node {$5$} (F);
    \path [-] (F) edge node {$4$} (C);
\end{scope}
\end{tikzpicture}
\end{frame}
\end{document}
```

Ignoring the problem with the edge labels from E to C and B to F for a moment, this will be a demonstration. This means that for each transition I need to change the labels above/below the nodes.  If I make a list of the labels for each transition, how can I get tikz to use the list?
Top Answer
samcarter
One possible approach is to (ab)use pgfmath:

```
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}


\makeatletter
\newcommand*{\slideinframe}{\number\beamer@slideinframe}
\makeatother

\def\mylist{{"foo","bar","baz"}}

\begin{document}



\begin{frame}
\frametitle{Demonstration}
\begin{tikzpicture}
\begin{scope}[every node/.style={fill=blue, circle,thick,draw, minimum size=1.3cm}]
    \node[label={[xshift=0em, yshift=-1em] \pgfmathparse{\mylist[\slideinframe-1]}\pgfmathresult}]  (A) at (0,5) {A};
    \node[label={[xshift=0em, yshift=-1em] \pgfmathparse{\mylist[\slideinframe-1]}\pgfmathresult}] (B) at (5,5) {B};
    \node[label={[xshift=0em, yshift=-1em] \pgfmathparse{\mylist[\slideinframe-1]}\pgfmathresult}] (C) at (10,5) {C};
    \node[label={[xshift=-1em, yshift=-6em] \pgfmathparse{\mylist[\slideinframe-1]}\pgfmathresult}] (D) at (0,0) {D};
    \node[label={[xshift=-1em, yshift=-6em] \pgfmathparse{\mylist[\slideinframe-1]}\pgfmathresult}] (E) at (5,0) {E};
    \node[label={[xshift=-1em, yshift=-6em]  \pgfmathparse{\mylist[\slideinframe-1]}\pgfmathresult}] (F) at (10,0) {F} ;
\end{scope}

\begin{scope}[>={Stealth[black]},
              every node/.style={fill=white,circle},
              every edge/.style={draw=red,very thick}]
    \path [-] (A) edge node {$1$} (B);
    \path [-] (D) edge node {$2$} (B);
    \path [-] (A) edge node {$3$} (D);
    \path [-] (D) edge node {$3$} (E);
    \path [-] (E) edge node {$2$} (F);
    \path [-] (E) edge node {$6$} (B);
    \path [-] (E) edge node {$4$} (C);
    \path [-] (B) edge node {$3$} (C);
    \path [-] (B) edge node {$5$} (F);
    \path [-] (F) edge node {$4$} (C);
\end{scope}
\end{tikzpicture}
\pause[3]
\end{frame}
\end{document}  
```

![document.gif](/image?hash=bd6097073cc91556575693c45040e2fcc3998700d9ef9e9080cf1ab545fc06b7)

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.