2

I have this tikz graph but the label of node A is covered by the edge. Is there a way to position it in the right corner of the node?

  \begin{figure}[H]
\centering
    \begin{tikzpicture}[font=\small, node distance={15mm}, thick, main/.style = {draw, circle}, scale=0.8,transform shape] 
\node[main , fill=black, label=left:{\small $B$}] (1) [] {}; 
  \node[main ,  label=right:{\small $A$}] (2) [ right of=1] {}; 
  \node[main , label=left:{\small $B$}] (1) [left  of=2] {}; 
\node[main , fill=black,label=above:{\small $C$}] (3) [right  of=2] {}; 
 \node[main, label=below:{\small $C^*$}] (4) [ below of=3] {};
 \node[main, label=below:{\small $R_C$}]  (5) [ below of=2]{}; 
 \node[main , label=above:{\small $B^*$}] (6) [above  of=1] {}; 
  \node[main , label=above:{\small $R_B$}] (7) [above  of=2] {}; 
\draw[->] (2) -- (1); 
\draw[->] (2) -- (3); 
\draw[->] (7) -- (6); 
  \draw[->] (2) -- (5); 
    \draw[->] (2) -- (7);
    \draw[->] (3) -- (4); 
\draw[->] (1) -- (6);
\draw[->] (5) -- (4); 
\end{tikzpicture}
\end{figure}

Also is there a way to make the graph curvy? like is there other packages that produces curvy graphs?

3
  • 2
    Put a complete code! In any case the answer of Your question is: 'label=above right:{\small $A$}]'. Commented Nov 6, 2023 at 22:04
  • 2
    Welcome. Please check the manual. The label position (that's the part before :) allows for any angle and you can also just change the anchor of the label independetly of the label position. You can also adjust the label distance. Commented Nov 6, 2023 at 23:08
  • 1
    @RaffaeleSantoro, please consider to write an answer.
    – Zarko
    Commented Nov 6, 2023 at 23:51

2 Answers 2

4

Your code is not complete. In any case the answer for Your question is a little correction to Your code: label=above right:{\small $A$}].

Complete working code:

\documentclass{article}
\usepackage{tikz}
\begin{document}


    \centering
        \begin{tikzpicture}[scale=3,font=\small, node distance={15mm}, thick, main/.style = {draw, circle}, scale=0.8,transform shape] 
            \node[main , fill=black, label=left:{\small $B$}] (1) [] {}; 
            \node[main ,  label=above right:{\small $A$}] (2) [ right of=1] {}; 
            \node[main , label=left:{\small $B$}] (1) [left  of=2] {}; 
            \node[main , fill=black,label=above:{\small $C$}] (3) [right  of=2] {}; 
            \node[main, label=below:{\small $C^*$}] (4) [ below of=3] {};
            \node[main, label=below:{\small $R_C$}]  (5) [ below of=2]{}; 
            \node[main , label=above:{\small $B^*$}] (6) [above  of=1] {}; 
            \node[main , label=above:{\small $R_B$}] (7) [above  of=2] {}; 
            \draw[->] (2) -- (1); 
            \draw[->] (2) -- (3); 
            \draw[->] (7) -- (6); 
            \draw[->] (2) -- (5); 
            \draw[->] (2) -- (7);
            \draw[->] (3) -- (4); 
            \draw[->] (1) -- (6);
            \draw[->] (5) -- (4); 
        \end{tikzpicture}
\end{document}

Output:

enter image description here

2
  • Thanks a lot. Worked great.
    – Moh
    Commented Nov 7, 2023 at 1:02
  • @Moh You are welcomed. Commented Nov 7, 2023 at 1:05
5

Just a small variation of nice @Raffaele Santoro answer (+1).

For your image i would define two nodes style, one for black dot, one for white, define nodes' labels stale by every label/.append style = ..., defineg arrows style by every edge/.style and for node positioning use positioning library:

\documentclass[margin=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                positioning}

\begin{document}
    \begin{tikzpicture}[baseline,
   node distance = 12mm and 12mm,
                   thick,
                   %on grid,
bdot/.style = {circle, draw, fill, inner sep=2.8pt,
                           label=#1, node contents = {}},
wdot/.style = {bdot=#1, fill=white},
every label/.append style = {node distance=2pt, inner sep=2pt, font=\footnotesize},
 every edge/.style = {draw, - Straight Barb}
                        ]
\node (1) [bdot=left:$B$];
\node (2) [wdot=above right:$A$, right=of 1];
\node (3) [bdot=above:$C$,  right=of 2];
\node (4) [wdot=below:$C^*$,below=of 3];
\node (5) [wdot=below:$R_C$,below=of 2];
\node (6) [wdot=above:$B^*$,above=of 1];
\node (7) [wdot=above:$R_B$,above=of 2];
\draw   (2) edge (1)    (2) edge (3) 
        (7) edge (6)    (2) edge (5) 
        (2) edge (7)    (3) edge (4) 
        (1) edge (6)    (5) edge (4);
    \end{tikzpicture}
\end{document}

enter image description here

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .