
He creado el siguiente diagrama usando Tikz, ¿hay alguna forma de mostrarlo correctamente? (Tal como está, se muestra con todos los nodos debajo del último, así que es un desastre)
\documentclass{article}
\usepackage[spanish]{babel}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows}
\tikzstyle{io} = [ellipse, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=blue!30]
\tikzstyle{arrow} = [thick,->,>=stealth]
\begin{document}
\begin{tikzpicture}[node distance=2cm]
\node (1) [io] {1 1 1 1};
\node (2) [io, below of=1] {2 1 0 1};
\node (3) [io, below of=2] {1 0 1 2};
\node (4) [io, below of=3] {2 0 0 2};
\node (5) [io, below of=4] {0 0 2 2};
\node (6) [io, below of=5] {0 1 2 1};
\node (7) [io, below of=6] {0 2 2 0};
\node (8) [io, below of=7] {1 2 1 0};
\node (9) [io, below of=8] {2 2 0 0};
\draw [arrow] (1) -- node {t1} (2);
\draw [arrow] (2) -- node {t2} (3);
\draw [arrow] (3) -- node {t1} (4);
\draw [arrow] (4) -- node {t3} (2);
\draw [arrow] (3) -- node {t3} (1);
\draw [arrow] (2) -- node {t3} (9);
\draw [arrow] (9) -- node {t2} (1);
\draw [arrow] (1) -- node {t3} (8);
\draw [arrow] (1) -- node {t2} (5);
\draw [arrow] (5) -- node {t1} (3);
\draw [arrow] (5) -- node {t3} (6);
\draw [arrow] (6) -- node {t1} (1);
\draw [arrow] (6) -- node {t3} (7);
\draw [arrow] (7) -- node {t1} (8);
\draw [arrow] (8) -- node {t2} (6);
\draw [arrow] (8) -- node {t1} (9);
\end{tikzpicture}
\end{document}
Por ejemplo, ¿cómo podría mostrar los nodos en un diseño circular?
Respuesta1
Dijiste "en un diseño circular". Aquí hay un ejemplo. Puede colocar los nodos alrededor del nodo (1) usando at (<angle:distance>)
una macro.
\documentclass{article}
\usepackage[spanish]{babel}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows}
\tikzstyle{io} = [ellipse, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=blue!30]
\tikzstyle{arrow} = [thick,->,>=stealth]
\begin{document}
\begin{tikzpicture}%[node distance=2cm]
\node (1) [io] {1 1 1 1};
\node (2) [io] at (45:2in) {2 1 0 1};
\node (4) [io] at (90:2in) {2 0 0 2};
\node (3) [io] at (135:2in) {1 0 1 2};
\node (5) [io] at (180:2in) {0 0 2 2};
\node (6) [io] at (225:2in) {0 1 2 1};
\node (7) [io] at (270:2in) {0 2 2 0};
\node (8) [io] at (315:2in) {1 2 1 0};
\node (9) [io] at (360:2in) {2 2 0 0};
\draw [arrow] (1) -- node[auto] {t1} (2); %% note auto option here onwards
%% for proper placement.
\draw [arrow] (2) -- node[auto] {t2} (3);
\draw [arrow] (3) -- node[auto] {t1} (4);
\draw [arrow] (4) -- node[auto,xshift=1cm] {t3} (2);
\draw [arrow] (3) -- node[auto] {t3} (1);
\draw [arrow] (2) -- node[auto] {t3} (9);
\draw [arrow] (9) -- node[auto] {t2} (1);
\draw [arrow] (1) -- node[auto] {t3} (8);
\draw [arrow] (1) -- node[auto] {t2} (5);
\draw [arrow] (5) -- node[auto] {t1} (3);
\draw [arrow] (5) -- node[auto] {t3} (6);
\draw [arrow] (6) -- node[auto] {t1} (1);
\draw [arrow] (6) -- node[auto] {t3} (7);
\draw [arrow] (7) -- node[auto] {t1} (8);
\draw [arrow] (8) -- node[auto] {t2} (6);
\draw [arrow] (8) -- node[auto] {t1} (9);
\end{tikzpicture}
\end{document}
Puede ajustar la topología usted mismo para adaptarla a sus necesidades.
Respuesta2
Aquí hay algo que debería ayudarlo a comenzar a usar la to
sintaxis y especificar los anclajes y in=
los out=
ángulos para las flechas.
Código:
\documentclass{article}
\usepackage[spanish]{babel}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows}
\tikzstyle{io} = [ellipse, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=blue!30]
\tikzstyle{arrow} = [thick,->,>=stealth]
\begin{document}
\begin{tikzpicture}[node distance=2cm]
\node (1) [io] {1 1 1 1};
\node (2) [io, below of=1] {2 1 0 1};
\node (3) [io, below of=2] {1 0 1 2};
\node (4) [io, below of=3] {2 0 0 2};
%\node (5) [io, below of=4] {0 0 2 2};
%\node (6) [io, below of=5] {0 1 2 1};
%\node (7) [io, below of=6] {0 2 2 0};
%\node (8) [io, below of=7] {1 2 1 0};
%\node (9) [io, below of=8] {2 2 0 0};
\draw [arrow] (1.south) -- node[right] {t1} (2.north);
\draw [arrow] (2.south) -- node[right] {t2} (3.north);
\draw [arrow] (3.south) -- node[right] {t1} (4.north);
\draw [arrow,out=70,in=-70] (4.east) to node[right] {t3} (2.east);
\draw [arrow,out=170,in=-170] (3.west) to node[left] {t3} (1.west);
%\draw [arrow] (2.south) -- node[right] {t3} (9.north);
%\draw [arrow] (9.south) -- node[right] {t2} (1.north);
%\draw [arrow] (1.south) -- node[right] {t3} (8.north);
%\draw [arrow] (1.south) -- node[right] {t2} (5.north);
%\draw [arrow] (5.south) -- node[right] {t1} (3.north);
%\draw [arrow] (5.south) -- node[right] {t3} (6.north);
%\draw [arrow] (6.south) -- node[right] {t1} (1.north);
%\draw [arrow] (6.south) -- node[right] {t3} (7.north);
%\draw [arrow] (7.south) -- node[right] {t1} (8.north);
%\draw [arrow] (8.south) -- node[right] {t2} (6.north);
%\draw [arrow] (8.south) -- node[right] {t1} (9.north);
\end{tikzpicture}
\end{document}