¿Cómo indicar niveles en un gráfico Tikz?

¿Cómo indicar niveles en un gráfico Tikz?

Tengo una red hecha en Tikz. El gráfico tiene tres niveles de nodos. Necesito dibujar una línea de puntos que conecte los nodos y colocar una etiqueta de nivel al lado del nodo más a la derecha ($m_1$, $j$ y $i$): Niveles 1, 2 y 3.

\documentclass[]{report}
\usepackage{tikz}
\usetikzlibrary{arrows, automata, arrows.meta, positioning, calc}

\begin{document}

\begin{figure}[h]   
\centering  
\begin{tikzpicture}[
> = stealth, % arrow head style
shorten > = 1pt, % don't touch arrow head to node
auto,
node distance = 3cm, % distance between nodes
semithick % line style
]

\tikzstyle{every state}=[
draw = black,
thick,
fill = white,
minimum size = 4mm
]
\node [dashed, state] (a) {$i$};
\node[state] (b) at ($ (a) + (45:1.5) $) {$j$};
\node[dashed, state] (c) at ($ (a) + (135:1.5) $) {$k$};
\node[state] (d) at ($ (c) + (45:2.1) $) {$m_1$};
\node[dashed, state] (e) at ($ (c) + (90:1.5) $) {$m_2$};
\node[state] (d1) at ($ (c) + (135:2.1) $) {$m_3$};

\path[->] (d) edge node {} (c);
\path[->] (d1) edge node {} (c);
\path[dashed,->] (e) edge node {} (c);
\path[->] (b) edge node {} (a);
\path[dashed, ->] (c) edge node {} (a);
\end{tikzpicture}
\label{fig:assembly-eg}
\end{figure}

\end{document}

Respuesta1

¡Bienvenido! ¿Algo como esto? Puede utilizar a local bounding boxpara alinear las etiquetas de los niveles. Tenga en cuenta también que \tikzstyleestá en desuso.

\documentclass[]{report}
\usepackage{tikz}
\usetikzlibrary{automata, arrows.meta, positioning, calc}

\begin{document}

\begin{figure}[h]   
\centering  
\begin{tikzpicture}[
> = stealth, % arrow head style
shorten > = 1pt, % don't touch arrow head to node
auto,
node distance = 3cm, % distance between nodes
semithick % line style
]
\begin{scope}[local bounding box=tree,every state/.style={draw = black,thick,
    fill = white,minimum size = 4mm}]
  \node [dashed, state] (a) {$i$};
  \node[state] (b) at ($ (a) + (45:1.5) $) {$j$};
  \node[dashed, state] (c) at ($ (a) + (135:1.5) $) {$k$};
  \node[state] (d) at ($ (c) + (45:2.1) $) {$m_1$};
  \node[dashed, state] (e) at ($ (c) + (90:1.5) $) {$m_2$};
  \node[state] (d1) at ($ (c) + (135:2.1) $) {$m_3$};
  \path ([xshift=1em]tree.east); %<-increase local bounding box
\end{scope}
\draw[dotted] (d1) -- (e) -- (d) -- (d-|tree.east) node[right]{1};
\draw[dotted] (c) -- (b) -- (b-|tree.east) node[right]{2};
\draw[dotted] (a) -- (a-|tree.east) node[right]{3};
\path[->] (d) edge node {} (c);
\path[->] (d1) edge node {} (c);
\path[dashed,->] (e) edge node {} (c);
\path[->] (b) edge node {} (a);
\path[dashed, ->] (c) edge node {} (a);
\end{tikzpicture}
\label{fig:assembly-eg}
\end{figure}

\end{document}

ingrese la descripción de la imagen aquí

información relacionada