There is the need to draw graphs like the following for a specific subject, the intent is to create a template where others can be created easily.
There are some requisites
- No need to mind about the color or the specific position.
tikz-externallibrary andbabel-portugueseare needed so the answer shoudnt have conflicts with these.
These are some ideas
- It would be the best to use the auto positioning of
graphsto create named nodes as vertices, so they can be used for relative positioning of labels.
Studying tikz-graphs the skeleton can be very easily created with the following:
\documentclass{standalone}
% Needed
\usepackage[portuguese]{babel} % Babel
% Tikz
\usepackage{tikz}
\usetikzlibrary{
babel,
external, % needed
graphs, graphdrawing,
arrows.meta,
}
\usegdlibrary{layered}
% External setup
\tikzexternalize[
up to date check={simple}, % faster check
figure list=true, % generate list of figures file
]
\tikzsetfigurename{figure.\arabic{part}.\arabic{section}.} % set figure names
% Tikz graphs style
\tikzstyle{mygraphsstyle}=[
% Arrows
> ={Stealth[round,sep]},
shorten > =3pt,
shorten < =3pt,
]
% Graphs style
\tikzset{
% Graphs style
graphs/every graph/.append style={
nodes={circle,draw,fill,fill opacity=0.1},
layered layout,
grow'=right,
level distance=6em,
sibling sep=6ex,
},
}
\begin{document}
\tikzset{external/remake next=true} % remake next graph
\begin{tikzpicture}[mygraphsstyle]
\graph{
% Layers
{[same layer] 4};
{[same layer] 6,5,7};
{[same layer] 8,9};
{[same layer] 10,11,12};
% Graph
1 -> 2 -> 3 -> 4 -> {6,5,7};
6 -> 8 -> 10 -> 13;
7 -> 9 -> 12 -> 13;
5 -> 7;
5 ->[dashed] 8;
9 -> 11 ->[dashed] 12;
};
\end{tikzpicture}
\end{document}




36.8.3 How To Generate Nodes Inside an Algorithm. Well, the "SimpleHuffman" described there is not that simple, i.e. gives a lot of chance to programming errors with long debug sessions ... – MS-SPO May 26 '23 at 04:17graphswould create them with\node (1) at (x,y){}so that i could later use\node[draw, below=3ex] at (1){1};for example. The main idea is to have a streamlined process, and havinggraphsplacing the nodes position to me would be perfect. – Felipe9 May 26 '23 at 18:05