1

Please consider the following picture:

Nodes design

I would like to create those nodes using the tikzpicture environment. Each must have a dividing line in the middle so that the node is divided into three sections (all contain numbers of up to 2 digits maximum). There are also some nodes that have a hyphen type arrow, which go to other nodes; these unions (with or without dots and with some text above the lines) must join or leave one of the left or right ends of the node, as you can see in the image.

Also, to make things easier, I hope that each node and each union will be available in an easy way, something like:

\begin{tikzpicture}
    \node at (0,0) (1) {1,0,0};
    \node at (1,-1) (2) {2,5,7};
    \node at (2,0) (3) {3,9,61};

    \draw (1) to [text=A(1)] (2) to [dotted] (3);
\end{tikzpicture}

(there are many more nodes and connections).

For the curious I am trying to imitate, with your huge hearts, the design of a Critical Path Method (CPM).

Thank you!!

EDIT:

Following the advice of Zarko and the example provided by Ignasi I created an MWE which generates 18 errors if I use the \usepackage[spanish]{babel} package (I need it, but this time I enclosed it to show you that the code works fine). How could I add this package that I need to the code?:

\documentclass{article}
%\usepackage[spanish]{babel}      % <-- HERE IS THE PACKAGE THAT I NEED
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{tasks}
\usepackage{vmargin}
\usepackage{enumitem}
\usepackage{hhline}
\usepackage{pdflscape}

\setpapersize{A4}
\setmargins{2.2cm}
{0.5cm}
{16.5cm}
{23.42cm}
{30pt}
{1cm}
{0pt}
{2cm}
\pagestyle{fancy}
\fancyhf{}
\cfoot{\large \thepage}
\renewcommand{\headrulewidth}{0pt}

\usepackage{colortbl}

\usepackage{pgfplots}
\usetikzlibrary{shapes.multipart, positioning}
\pgfplotsset{compat=1.8}

\begin{document}

\begin{tikzpicture}[
    trinode/.style={
    circle split,
    draw,
    path picture={\draw (path picture bounding box.center)--(path picture bounding box.south);}}
    ]

    %\node[trinode] (1) {99\nodepart{lower} 99\ \ 99};
    \node[trinode] at (0,0) (1) {99\nodepart{lower} 99\ \ 99};

    %\node[trinode, below right=of 1] (2) {99\nodepart{lower} 99\ \ 99};
    \node[trinode] at (2,-2) (2) {99\nodepart{lower} 99\ \ 99};

    %\node[trinode, above right=of 2] (3) {99\nodepart{lower} 99\ \ 99};
    \node[trinode] at (4,0) (3) {99\nodepart{lower} 99\ \ 99};

    \draw[->] (1)--(2) node[midway, right] {A(1)};
    \draw[->,dashed] (2)--(3);
\end{tikzpicture}

\end{document}
  • 2
    please make your code snippet compilable small document. – Zarko Jul 9 '18 at 8:15
  • Hi @Zarko. I am sorry but no MWE created because it is focused on your imagination of code! Using article document and tikzpicture environment (with some libraries, like arrow) I think it's all you need. If this is not sufficient let me know. – manooooh Jul 9 '18 at 8:23
  • 3
    oh, thank you very much for your concern for my imagination :-). however, you should provide complete document. if you do so, i or anyone else still be able to express imagination ... – Zarko Jul 9 '18 at 9:01
  • @Zarko please see edit. – manooooh Jul 9 '18 at 19:39
  • well, meantime you got nice answer. see my comment below it. – Zarko Jul 9 '18 at 19:50
4

I've seen this kind of nodes somewhere in TeX.SX but as I don't know who to search them I provide a solution with a circle split.

These nodes uses two texts upper and lower separated by an horizontal line. My solution declares two lower numbers as a common text and the path picture command draws the vertical line.

Connections between nodes and labels for paths are the usual ones.

\documentclass[tikz,border=2mm]{standalone}

\usetikzlibrary{babel, positioning, shapes.multipart}

\begin{document}

\begin{tikzpicture}[
    trinode/.style={
            circle split,
            draw,
            path picture={\draw (path picture bounding box.center)--(path picture bounding box.south);}}]

\node[trinode] (1) {99\nodepart{lower} 99\ \ 99};

\node[trinode, below right=of 1] (2) {99\nodepart{lower} 99\ \ 99};

\node[trinode, above right=of 2] (3) {99\nodepart{lower} 99\ \ 99};

\draw[->] (1)--(2) node[midway, right]{A(1)};
\draw[->,dashed] (2)--(3);
\end{tikzpicture}
\end{document}

enter image description here

  • 2
    This one? tex.stackexchange.com/questions/58993/… – percusse Jul 9 '18 at 10:47
  • It looks awesome @Ignasi! However if I load a package (specifically the \usepackage[spanish]{babel}) it generates 18 errors. Please consider the MWE in my edit. – manooooh Jul 9 '18 at 19:40
  • 1
    @manooooh, you need to add totikz librarybabel, i.e.; \usetikzlibrary{shapes.multipart, positioning, babel} – Zarko Jul 9 '18 at 19:49
  • 1
    @manooooh: yes. fix a minimum size large enough for two digits and it will be keeped on one digit nodes. – Ignasi Jul 10 '18 at 6:37
  • 1
    @manooooh the second option is the correct one, but 5mm is to short. Try without minimum size but two digit numbers. View the result at 100% and neasure the node. Try with this value as minimum size and see what happens. – Ignasi Jul 11 '18 at 17:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.