2

I want to add labels inside each of the three cycles formed by arcs in the graph. The label should say $b_1$,$b_2$, and $b_3$. The size can be smaller but preferably the same as the size of the labels within the nodes.

\documentclass[10pt]{article}
\textwidth= 5.00in
\textheight= 7.4in
\topmargin = 30pt
\evensidemargin=0pt
\oddsidemargin=55pt
\headsep=17pt
\parskip=.8pt
\parindent=12pt
\font\smallit=cmti10
\font\smalltt=cmtt10
\font\smallrm=cmr9

\usepackage{tikz}
\usetikzlibrary{positioning,shapes.misc,shapes.geometric, graphs}

\begin{document}


\begin{figure}[h]
\begin{center}
    \begin{tikzpicture}[node distance=14mm and 18mm, every node/.style=draw, on grid]
        \node (u1) [circle] {$a_1$};
        \node (u2) [circle, right=of u1] {$a_2$};
        \node (v1) [circle, below=of u1] {$a_1$};
        \node (v2) [circle, below=of u2] {$a_3$};
        \node (w1) [circle, below=of v1] {$a_2$};
        \node (w2) [circle, below = of v2] {$a_3$};
        \graph [use existing nodes] {
            u1 -> [bend left] u2; %node [pos=0.5, above, black, sloped] {label};
            u2 -> [bend left] u1;                      
            v1 -> [bend left] v2;
            v2 -> [bend left] v1;
            w1 -> [bend left] w2;
            w2 -> [bend left] w1;            
        };
    \end{tikzpicture}
\end{center}
\end{figure}
\end{document}

1 Answer 1

2

Here are three ways.

  1. Create (but don't draw) a path between the relevant nodes. Place a node on that path.
  2. Place a node at the midpoint between the relevant nodes (requires calc library).
  3. Place a node right of the left node, but use half the node distance.

enter image description here

Note: I created a style called mynode instead of using every node since you now have some nodes that you do not want drawn.

\documentclass[10pt]{article}

\usepackage{tikz}
\usetikzlibrary{positioning, graphs, calc}

\begin{document}


\begin{figure}[h]
\begin{center}
    \begin{tikzpicture}[node distance=14mm and 18mm, mynode/.style={draw,circle}, on grid]
        \node (u1) [mynode] {$a_1$};
        \node (u2) [mynode, right=of u1] {$a_2$};
        \node (v1) [mynode, below=of u1] {$a_1$};
        \node (v2) [mynode, below=of u2] {$a_3$};
        \node (w1) [mynode, below=of v1] {$a_2$};
        \node (w2) [mynode, below = of v2] {$a_3$};
        \graph [use existing nodes] {
            u1 -> [bend left] u2; %node [pos=0.5, above, black, sloped] {label};
            u2 -> [bend left] u1;                      
            v1 -> [bend left] v2;
            v2 -> [bend left] v1;
            w1 -> [bend left] w2;
            w2 -> [bend left] w1;            
        };
        \path(u1)--node{$b_1$}(u2);
        \node at ($(v1)!.5!(v2)$){$b_2$}; %requires calc library
        \node[right=9mm of w1] {$b_3$};
    \end{tikzpicture}
\end{center}
\end{figure}
\end{document}

You must log in to answer this question.

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