在下面的乳胶图中绘制箭头

在下面的乳胶图中绘制箭头
\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}

在此图中,我想在绿色边缘放置箭头,也就是说,我想用绿色的有向边替换绿色边缘。如何做到这一点。

答案1

\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}

带箭头的图表

答案2

另一种箭头:

在此处输入图片描述

通过使用相对坐标:

\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}

笔记:如果您不喜欢有标签的节点,只需label=...从每个节点选项中删除即可。例如,如以下稍短的代码:

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

这使:

在此处输入图片描述

相关内容