因此,我使用 TikZ 包创建了一个非常简单的图,但问题是成本和一些边相互重叠。我必须创建一个多阶段图,所以基本上我需要一种方法来重新分配成本,或者也许可以提出另一种解决方案...
这是图表示例:
begin{tikzpicture}[->,>=stealth',shorten >=2pt,auto,node distance=4cm,
semithick]
\tikzstyle{every state}=[fill=gray,draw=none,text=white]
\tikzstyle{inicio}=[fill=black,draw=none,text=white]
\tikzstyle{final}=[fill=black,draw=none,text=white]
\node[state, inicio] (A) {$0$};
\node[state] (M12) [below right of=A] {$M12$};
\node[state] (M11) [above of=M12] {$M11$};
\node[state] (M21) [ right of=M11] {$M21$};
\node[state] (M22) [ right of=M12] {$M22$};
\path
(A) edge node {2} (M11)
edge node {3} (M12)
(M11) edge node {5} (M21)
edge node {2} (M22)
(M12) edge node {5} (M21)
edge node {2} (M22);
\end{tikzpicture}
答案1
这就是你想要实现的吗?
\documentclass[border=0.1in]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows,automata}
\begin{document}
\begin{tikzpicture}[->,>=stealth',shorten >=2pt,auto,node distance=4cm,
semithick]
\tikzstyle{every state}=[fill=gray,draw=none,text=white]
\tikzstyle{inicio}=[fill=black,draw=none,text=white]
\tikzstyle{final}=[fill=black,draw=none,text=white]
\node[state, inicio] (A) {$0$};
\node[state] (M12) [below right of=A] {$M12$};
\node[state] (M11) [above of=M12] {$M11$};
\node[state] (M21) [ right of=M11] {$M21$};
\node[state] (M22) [ right of=M12] {$M22$};
\path
(A) edge node {2} (M11)
edge node {3} (M12)
(M11) edge node {5} (M21)
edge node[near end,above right] {2} (M22)
(M12) edge node[near start,above left] {5} (M21)
edge node {2} (M22);
\end{tikzpicture}
\end{document}