2

I made this files how to write under and over the "arrows" please

\documentclass[12pt]{report}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{decorations.markings}
\linespread{1.5} 
\textwidth=16truecm \textheight=23truecm  \voffset=-1truecm
\hoffset=-1 truecm \thispagestyle{empty}

\begin{document}
\begin{tikzpicture}[node distance=2cm]  

\node (A) at (0,4) {$1$};
\node (B) at (   4,2) {$2$};
\node (C) at (  4,-1) {$3$};
\node (D) at (-4,-1) {$4$};
\node (E) at (-4,2) {$5$};


  \draw[
        decoration={markings, mark=at position 0.625 with {\arrow{>}}},
        postaction={decorate}
        ]
        (0,4) circle (0.4);
    \draw[ 
        decoration={markings, mark=at position 0.125 with {\arrow{>}}},
        postaction={decorate}
        ]
        (4,2) circle (0.4);

  \draw[ 
        decoration={markings, mark=at position 0.125 with {\arrow{>}}},
        postaction={decorate}
        ]
        (4,-1) circle (0.4);
        \draw[ 
        decoration={markings, mark=at position 0.125 with {\arrow{>}}},
        postaction={decorate}
        ]
        (-4,-1) circle (0.4);
        \draw[ 
        decoration={markings, mark=at position 0.125 with {\arrow{>}}},
        postaction={decorate}
        ]
        (-4,2) circle (0.4);
    % draw the connecting line
    \draw[ 
        decoration={markings, mark=at position 0.5 with {\arrow{>}}},
        postaction={decorate}
        ]
          (0,3.6)--(3.6,1.9) ;
          \draw[ 
        decoration={markings, mark=at position 0.5 with {\arrow{>}}},
        postaction={decorate}
        ]
          (3.6,1.9)--(3.6,-1);
          \draw[ 
        decoration={markings, mark=at position 0.5 with {\arrow{>}}},
        postaction={decorate}
        ]
          (3.6,-1)--(-3.6,-1);
           \draw[ 
        decoration={markings, mark=at position 0.5 with {\arrow{>}}},
        postaction={decorate}
        ]
          (-3.6,-1)--(-3.6,2);
          \draw[ 
        decoration={markings, mark=at position 0.5 with {\arrow{>}}},
        postaction={decorate}
        ]
       (0,3.6) -- (-3.6,2);
           \draw[ 
        decoration={markings, mark=at position 0.5 with {\arrow{>}}},
        postaction={decorate}
        ]
          (0,3.6)--(-3.6,-1);
           \draw[ 
        decoration={markings, mark=at position 0.5 with {\arrow{>}}},
        postaction={decorate}
        ]
          (0,3.6)--(3.6,-1);
            \draw[ 
        decoration={markings, mark=at position 0.5 with {\arrow{>}}},
        postaction={decorate}
        ]
          (3.6,-1)--(-3.6,2);
           \draw[ 
        decoration={markings, mark=at position 0.5 with {\arrow{>}}},
        postaction={decorate}
        ]
          (3.6,1.9)--(-3.6,-1);

    % draw the two black dots
    \fill (0,3.6) circle (0.1); 
    \fill (3.6,1.9) circle (0.1); 
    \fill (3.6,-1) circle (0.1); 
    \fill (-3.6,-1) circle (0.1); 
     \fill (-3.6,2) circle (0.1); 
    \end{tikzpicture}


\end{document}
3

2 Answers 2

8

for starting point:

enter image description here

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows, calc, decorations.markings, positioning, quotes}

\begin{document}
    \begin{tikzpicture}[
node distance = 20mm and 30mm,
     C/.style = {circle, draw=red, inner sep=0pt, outer sep=0pt, minimum size=8mm,
                 },
   dot/.style = {circle, fill, inner sep=0pt, minimum size=2mm,
                 node contents={}},
     L/.style = {decoration={markings, mark=at position 0.4 with {\arrow{>}}},
                 postaction={decorate}},
every edge quotes/.append style = {anchor=north, sloped, font=\footnotesize},
every edge/.append style = {L}
                 ]
% main nodes
\node (A) [dot];
\node (B) [dot,below right=of A];%  {2};
\node (C) [dot,below=of B];%        {3};
\node (E) [dot,below  left=of A];%  {5};
\node (D) [dot,below=of E];%        {4};
% dots
\draw[L]    ($(A)+(0, 5mm)$) circle (5mm) node {1};
\draw[L]    ($(B)+( 5mm,0)$) circle (5mm) node {2};
\draw[L]    ($(C)+( 5mm,0)$) circle (5mm) node {3};
\draw[L]    ($(D)+(-5mm,0)$) circle (5mm) node {4};
\draw[L]    ($(E)+(-5mm,0)$) circle (5mm) node {5};
% draw the connecting line
\path   (A) edge ["some text"]    (B)
        (B) edge ["some text"]    (C)
        (C) edge ["some text"]    (D)
        (D) edge ["some text"]    (E)
        (E) edge ["some text"]    (A)
%
        (E) edge [pos=0.3, "some text"] (C)
        (D) edge [pos=0.3, "{$H(\{1\},\{2\})=\frac{1}{5}$}"] (B)
        ;
    \end{tikzpicture}
\end{document}

image is not completed, even for correct arrows orientation i'm not sure. this is simple to finish and with interchanges of coordinates easy to accomplish.

for text on paths i use quotes library. its syntax is simple:

 \draw (<coordinate 1>) edge ["text"] (coordinate 2);

to appear on desired side of arrows, to have desired font size, etc, i add to options to edge style:

every edge quotes/.append style = {anchor=north, sloped, font=\footnotesize}

also you can see, that i use relative positioning defined by library positioning od for driwing of edges names of nodes dot. all this,. together to common style for decorations of paths, i define style L.

11
  • Please can i use \documentclass[12pt]{report}?
    – Vrouvrou
    Jan 9, 2018 at 19:54
  • i have an error at the line 29
    – Vrouvrou
    Jan 9, 2018 at 19:55
  • are you here? please answer me
    – Vrouvrou
    Jan 9, 2018 at 19:59
  • ups, in copying code one comma was lost: correct is every edge quotes/.append style = {anchor=north, sloped, font=\footnotesize}, . now corrected and tested again. it works as advertised :-).
    – Zarko
    Jan 9, 2018 at 20:04
  • it works but tht image is small why ? what about the document class
    – Vrouvrou
    Jan 9, 2018 at 20:07
0

edge labels, written with quotes, is not trivial positioning above and below, when they are sloped with edge, hence new answer. as (rude) solution is use of nodes as follows:

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows, calc, decorations.markings, positioning, quotes}

\begin{document}
    \begin{tikzpicture}[
node distance = 20mm and 30mm,
     C/.style = {circle, draw=red, inner sep=0pt, outer sep=0pt, minimum size=8mm,
                 },
   dot/.style = {circle, fill, inner sep=0pt, minimum size=2mm,
                 node contents={}},
     L/.style = {decoration={markings, mark=at position 0.4 with {\arrow{>}}},
                 postaction={decorate}},
    EN/.style = {sloped, font=\footnotesize},
every edge/.append style = {L}
                 ]
% main nodes
\node (A) [dot];
\node (B) [dot,below right=of A];%  {2};
\node (C) [dot,below=of B];%        {3};
% dots
\draw[L]    ($(A)+(0, 5mm)$) circle (5mm) node {1};
\draw[L]    ($(B)+( 5mm,0)$) circle (5mm) node {2};
\draw[L]    ($(C)+( 5mm,0)$) circle (5mm) node {3};
% draw the connecting line
\draw   (A) edge node[EN,above] {some text above}
                 node[EN,below] {some text below} (B)
        (B) edge node[EN,below] {text}      (C)
        ;
    \end{tikzpicture}
\end{document}

enter image description here

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