# TikZ: How to distinguish multiple vertices with the same id?

(Almost minimal) working example:

\documentclass{beamer}
\usepackage{tikz}
\usepackage{verbatim}
\usetikzlibrary{arrows,shapes}

\begin{document}

\pgfdeclarelayer{background}
\pgfsetlayers{background,main}

\begin{frame}
\frametitle{Parallel Boruvka's}
\tikzstyle{vertex}=[circle,fill=black!25,minimum size=20pt,inner sep=0pt]
\tikzstyle{selected vertex} = [vertex, fill=red!24]
\tikzstyle{root} = [vertex, fill=blue!24]
\tikzstyle{edge} = [draw,thick,-]
\tikzstyle{weight} = [font=\small]
\tikzstyle{selected edge} = [draw,line width=5pt,-,red!50]
\tikzstyle{dfs} = [draw,line width=5pt,-,blue!20]

\begin{figure}
\begin{tikzpicture}[scale=1.8, auto,swap]
\foreach \pos/\name/\fr in {{(0,1)/1/1},{(0,1)/2/3}, {(1,1)/2/1}, {(2,1)/3/1},  {(2,1)/2/3}}
\node<\fr->[vertex] (\name) at \pos {$\name$};
\foreach \source/ \dest /\weight in {1/2/3,2/3/1}
\path[edge] (\source) -- node[weight] {$\weight$} (\dest);
\end{tikzpicture}
\end{figure}
\end{frame}
\end{document}


Output on second and third slide:

What I'd like to achieve is that all vertices have the same id as on slide 3 but the edge weights stay the same as they are on the second slide. Can this be done?

A (silly) side question: Where can I find documentation that would help me in this case?/ All I can find are examples somehow but no real explanations.

You are assigning the name 2 to different nodes on different slides. To avoid this, label the nodes uniquely, even if the node content is the same:

\documentclass{beamer}

\usepackage{tikz}

\begin{document}

\begin{frame}
\frametitle{Parallel Boruvka's}
\tikzset{
vertex/.style = {circle,fill=black!25,minimum size=20pt,inner sep=0pt},
edge/.style = {draw,thick,-},
weight/.style = {font=\small},
}
\begin{figure}
\begin{tikzpicture}[scale=1.8, auto,swap]
\foreach \pos/\name/\fr/\label in {{(0,1)/1/1/1},{(0,1)/2/3/2a}, {(1,1)/2/1/2}, {(2,1)/3/1/3},  {(2,1)/2/3/2b}}
\node<\fr->[vertex] (\label) at \pos {$\name$};
\foreach \source/ \dest /\weight in {1/2/3,2/3/1}
\path[edge] (\source) -- node[weight] {$\weight$} (\dest);
\end{tikzpicture}
\end{figure}
\end{frame}

\end{document}


Note that you should use \tikzset and not \tikzstyle as the latter is deprecated.