避免边缘和标签自动重叠

避免边缘和标签自动重叠

我想避免边缘和标签重叠。我见过不同的解决方案,但都需要手动调整。然而,我需要制作几个像下面这样的图表,发现手动调整边缘的起点和终点以及标签的放置位置太耗时了。

\begin{figure}[h]
    \centering
    \begin{tikzpicture}[
    roundnode/.style={circle, draw=green!60, fill=green!5, very thick, minimum size=7mm}
    ]

    %Nodes
    \node[roundnode](s) at (4,4) {s};
    \node[roundnode](1) at (-2,2) {1};
    \node[roundnode](2) at (2,2) {2};
    \node[roundnode](3) at (6,2) {3};
    \node[roundnode](4) at (10,2) {4};
    \node[roundnode](t) at (4,0) {t};

    %Lines
    \draw[thick, ->] (s) edge [bend right=15] node[pos=0.5, above]{8-$\phi$} (1);
    \draw[thick, ->] (1) edge [bend right=15] node[pos=0.5, above]{$\phi$} (s);
    \draw[thick, ->] (s) -- (3) node[pos=0.5, above]{8};
    \draw[thick, ->] (s) -- (4) node[pos=0.5, above]{8};
    \draw[thick, ->] (2) -- (1) node[pos=0.5, above]{$\phi$};
    \draw[thick, ->] (2) edge [bend right=15] node[pos=0.5, above]{$1-\phi$} (3);
    \draw[thick, ->] (3) edge [bend right=15] node[pos=0.5, above]{$\phi$} (2);
    \draw[thick, ->] (3) edge [bend right=15] node[pos=0.5, above]{$1-\phi$} (4);
    \draw[thick, ->] (4) edge [bend right=15] node[pos=0.5, above]{$\phi$} (3);
    \draw[thick, ->] (1) -- (t) node[pos=0.5, above]{8};
    \draw[thick, ->] (2) -- (t) node[pos=0.5, above]{8};
    \draw[thick, ->] (4) edge [bend right=15] node[pos=0.5, above]{$8-\phi$} (t);
    \draw[thick, ->] (t) edge [bend right=15] node[pos=0.5, above]{$\phi$} (4);

    \end{tikzpicture}
    \caption{Flow increased through path $P_1$}
\end{figure}

相关内容