0
\documentclass[a4paper,12pt,twoside]{report}
\usepackage{pgf,tikz}
\begin{document}

\begin{figure}[hbt!]
    \begin{center}

\begin{tikzpicture}[scale=0.95,
            thick,
            acteur/.style={
                circle,
                fill=black,
                thick,
                inner sep=2pt,
                minimum size=0.2cm,scale=0.65
            }
            ] 
            \node (a1) at (0,0) [acteur,label=left:\footnotesize{}]{}; 

            \node (a2) at (1.5,0)  [acteur,label=left:\footnotesize{}]{};           

            \node (a3) at (1.5,1.5) [acteur,label=left:\footnotesize{}]{};     

            \node (a4) at (0,1.5) [acteur,label=left:\footnotesize{}]{};         

                \node (a5) at (.75,3) [acteur,label=left:\footnotesize{}]{};         


            \draw [green]  (a1) -- (a2); 
            \draw  [blue](a2) -- (a3); 
            \draw [green]  (a3) -- (a4);
            \draw  [red](a4) -- (a1);
            \draw [blue] (a4) -- (a5);
            \draw [red]  (a5) -- (a3);
        \end{tikzpicture}
    %   \caption{ Candidate for maximizing algebraic connectivity in $\mathcal{B}_4$}\label{F2}
    \end{center}
\end{figure} 
\end{document}

In this graph, I want to place arrows in the green edges, that is, I want to replace the green edges with directed edges with green color. How to do that.

2 Answers2

2
\documentclass[a4paper,12pt,twoside]{report}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\begin{document}
\begin{figure}[hbt!]
\begin{center}
\begin{tikzpicture}[scale=0.95,
            thick,
            acteur/.style={
                circle,
                fill=black,
                thick,
                inner sep=2pt,
                minimum size=0.2cm,scale=0.65
            }
            ] 
            \node (a1) at (0,0) [acteur,label=left:\footnotesize{}]{}; 
            \node (a2) at (1.5,0)  [acteur,label=left:\footnotesize{}]{};           
            \node (a3) at (1.5,1.5) [acteur,label=left:\footnotesize{}]{};     
            \node (a4) at (0,1.5) [acteur,label=left:\footnotesize{}]{};         
            \node (a5) at (.75,3) [acteur,label=left:\footnotesize{}]{};                
            \draw [green, decoration={markings, mark=at position 0.5 with {\arrow{>}}}, postaction={decorate}]  (a1) -- (a2); 
            \draw  [blue](a2) -- (a3); 
            \draw [green, decoration={markings, mark=at position 0.5 with {\arrow{>}}}, postaction={decorate}]  (a3) -- (a4);
            \draw  [red](a4) -- (a1);
            \draw [blue] (a4) -- (a5);
            \draw [red]  (a5) -- (a3);
        \end{tikzpicture}
    %   \caption{ Candidate for maximizing algebraic connectivity in $\mathcal{B}_4$}\label{F2}
    \end{center}
\end{figure} 
\end{document}

Graph with arrows

0

An alternative arrows:

enter image description here

By use of the relative coordinates:

\documentclass[border=3.141592]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                calc,
                positioning}

\begin{document} \begin{tikzpicture}[ node distance = 15mm and 15 mm, acteur/.style = {circle, fill=black, inner sep=2pt, outer sep=0pt, node contents={}}, every edge/.append style = {-{Straight Barb[scale=0.8]}}, every label/.append style = {font=\footnotesize}, every path/.style = {draw, thick}, ] \node (a1) [acteur,label=left: 1]; \node (a2) [acteur,right=of a1, label=right: 2]; \node (a3) [acteur,above=of a2, label=right: 3]; \node (a4) [acteur,left=of a3, label=left:4]; \node (a5) [acteur,above=of $(a3)!0.5!(a4)$, label=left:5]; \draw [green] (a1) edge (a2) (a3) edge (a4); \draw [blue] (a2) -- (a3) (a4) -- (a5); \draw [red] (a4) -- (a1) (a5) -- (a3); \end{tikzpicture} \end{document}

Note: If you not like to have labeled nodes, simple delete label=... from each node options. F for example as the following slightly shorter code:

    \end{scope}
    \end{tikzpicture}
\end{document}

which gives:

enter image description here

Zarko
  • 296,517