9

I need a small text under node 4, 0 and 3. Does anybody know how to do that? This is what I have

\documentclass{article}

\usepackage{tikz}  
\usetikzlibrary{arrows.meta}  
\begin{document}  
\begin{tikzpicture}  
\begin{scope}[every node/.style={circle,thick,draw}]  
    \node (0) at (0,0) {0};  
    \node (1) at (1,1) {1};  
    \node (2) at (1,-1) {2};  
    \node (3) at (2,0) {3};  
    \node (4) at (-2,0) {4};  
\end{scope}  

\begin{scope}[>={Stealth[black]},
              every node/.style={fill=white,circle},
              every edge/.style={draw=red,very thick}]  
    \path [->] (0) edge (4);  
    \path [->] (0) edge (1);  
    \path [->] (1) edge (2);  
    \path [->] (0) edge (2);  
    \path [->] (1) edge (3);  
    \path [->] (2) edge (3);  
\end{scope}  
\end{tikzpicture}  
\end{document}  
6
\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows.meta}

\begin{document}
    \begin{tikzpicture}[
         C/.style = {circle,thick,draw, inner sep=2pt},
every edge/.style = {draw=red,very thick,-{Stealth[black]}},
                        ]
\node[C,label=below:text]   (0) at (0, 0) {0};
\node[C]                    (1) at (1, 1) {1};
\node[C]                    (2) at (1,-1) {2};
\node[C,label=below:text]   (3) at (2, 0) {3};
\node[C,label=below:text]   (4) at (-2,0) {4};
%
\draw[->]   (0) edge (4) 
            (0) edge (1)
            (1) edge (2) 
            (0) edge (2) 
            (1) edge (3)
            (2) edge (3);
    \end{tikzpicture}
\end{document}

In using labels you need to consider, that labels are actually nodes, therefore defined style for main nodes with every node/.style affected labels to. Above code gives:

enter image description here

9

Use the [label=<position>:<text>] option format along with your nodes, like this:

\documentclass{article}

\usepackage{tikz}  
\usetikzlibrary{arrows.meta}  
\begin{document}  
\begin{tikzpicture}  
\begin{scope}[every node/.style={circle,thick,draw}]  
    \node[label=below:text] (0) at (0,0) {0};  
    \node (1) at (1,1) {1};  
    \node (2) at (1,-1) {2};  
    \node[label=below:text] (3) at (2,0) {3};  
    \node[label=below:text] (4) at (-2,0) {4};  
\end{scope}  

\begin{scope}[>={Stealth[black]},
              every node/.style={fill=white,circle},
              every edge/.style={draw=red,very thick}]  
    \path [->] (0) edge (4);  
    \path [->] (0) edge (1);  
    \path [->] (1) edge (2);  
    \path [->] (0) edge (2);  
    \path [->] (1) edge (3);  
    \path [->] (2) edge (3);  
\end{scope}  
\end{tikzpicture}  
\end{document} 

result

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.