我怎样才能使这个图表看起来更好一些?

我怎样才能使这个图表看起来更好一些?

我的图表如下所示:

在此处输入图片描述

我对此有几个问题:

  1. 我期望外部边缘具有相似的尺寸。如您所见,侧面的边缘比顶部/底部的边缘长得多。有没有办法让它们均匀,并且图形看起来更“圆”?
  2. 节点大小不同。中间的节点太大了。有没有办法让它们大小相同(可能让所有标签都变小,这样节点就不会太大)?
  3. 边缘上的标签几乎是随机放置的。有没有办法让它更加一致?

我的代码:

\begin{tikzpicture}[->,node distance=3cm,auto,
                   main node/.style={circle,draw}]

\node[main node] (0) {\(f1, f2, f3\)};
\node[main node] (1) [above of=0] {\(f1, f2\)};
\node[main node] (2) [above right of=0] {\(f2\)};
\node[main node] (3) [below right of=0] {\(f2, f3\)};
\node[main node] (4) [below of=0] {\(f3\)};
\node[main node] (5) [below left of=0] {\(f1, f3\)};
\node[main node] (6) [above left of=0] {\(f1\)};

\path[every node/.style={font=\sffamily\small}]
(0) edge node {\(f3\)} (1)
(0) edge node {\(f1\)} (3)
(0) edge node {\(f2\)} (5)
(1) edge node {\(f1\)} (2)
(1) edge node {\(f2\)} (6)
(3) edge node {\(f3\)} (2)
(3) edge node {\(f2\)} (4)
(5) edge node {\(f1\)} (4)
(5) edge node {\(f3\)} (6);

\end{tikzpicture}

答案1

在此处输入图片描述

\documentclass[tikz,margin=3mm]{standalone}
\usetikzlibrary{arrows.meta, 
                quotes}

\begin{document}
\begin{tikzpicture}[
        MN/.style = {%Main Node
                     circle, draw, minimum size=15mm, font=\footnotesize,
                     inner sep = 0pt, outer sep=0pt},
every edge/.style = {draw, -Stealth}
                    ]
\node[MN] (mn0)             {$f1, f2, f3$};
\node[MN] (mn1) at ( 30:3)  {$f1, f2$};
\node[MN] (mn2) at ( 90:3)  {$f2$};
\node[MN] (mn3) at (150:3)  {$f2, f3$};
\node[MN] (mn4) at (210:3)  {$f3$};
\node[MN] (mn5) at (270:3)  {$f1, f3$};
\node[MN] (mn6) at (330:3)  {$f1$};

\foreach \i in {1,3,5}
\path   (mn0) edge["$f3$"]    (mn\i);
\path   (mn1) edge["$f1$" ']  (mn2)
        (mn1) edge["$f2$"]    (mn6)
        (mn3) edge["$f3$"]    (mn2)
        (mn3) edge["$f2$" ']  (mn4)
        (mn5) edge["$f1$"]    (mn4)
        (mn5) edge["$f3$" ']  (mn6);
\end{tikzpicture}
\end{document}

或者为边缘标签添加样式:

every edge quotes/.style = {font=\footnotesize, inner sep=2pt, sloped, auto}

在此处输入图片描述

答案2

只是为了好玩:使用 TiZ 模数运算。有助于避免错误标记(当然,如果我理解其中的逻辑的话)。

\documentclass[tikz,border=3mm]{standalone}
\begin{document}
\begin{tikzpicture}[circ/.style={circle,draw,minimum size=4em}]
 \node[circ] (n0) {$f_1,f_2,f_3$};
 \foreach \X [evaluate=\X as \NextX using {int(1+mod(\X,3))},
    evaluate=\X as \PrevX using {int(1+Mod(\X-2,3))}] in {1,2,3}
  {
  \path (-150+\X*120:3) node[circ] (n\the\numexpr2*\X-1) 
    {$\ifnum\PrevX<\NextX
    f_\PrevX,f_\NextX
    \else
    f_\NextX,f_\PrevX
    \fi$}
   (-90+\X*120:3) node[circ] (n\the\numexpr2*\X) {$f_\PrevX$}
  ;
  \draw[-stealth] (n0) -- (n\the\numexpr2*\X-1) node[midway,auto]{$f_\X$};
  }
 \foreach \X [evaluate=\X as \NextX using {int(1+mod(\X,3))},
    evaluate=\X as \PrevX using {int(1+Mod(\X-2,3))}] in {1,2,3}
  {
  \draw[-stealth]  (n\the\numexpr2*\X-1) -- (n\the\numexpr2*\X)
   node[midway,auto]{$f_\NextX$};
  \ifnum\X=1
  \draw[-stealth]  (n\the\numexpr2*\X-1) -- (n6)
   node[midway,auto]{$f_\PrevX$};
  \else
  \draw[-stealth]  (n\the\numexpr2*\X-1) -- (n\the\numexpr2*\X-2)
   node[midway,auto]{$f_\PrevX$};
  \fi 
  }
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容