如何使用 tkz-graph 繪製自迴圈和平行邊

如何使用 tkz-graph 繪製自迴圈和平行邊

如何在 v_3 處繪製自環以及 v_4 和 v_3 之間的平行邊\usepackage{tkz-graph}(如果 tkz-graph 不是繪製圖形的最佳方法,請提及繪製圖形的最佳方法)

另外,如何將邊命名為 e_1、e_2、...、e_6?

\documentclass[border=10pt]{standalone}
\usepackage{tkz-graph}
\usetikzlibrary{calc} 
\GraphInit[vstyle=normal]
        
\begin{document}
 \begin{tikzpicture}
     \SetGraphUnit{2}
     \begin{scope}[rotate=-135]
            \Vertices{circle}{$v_1$,$v_2$,$v_3$,$v_4$}
     \end{scope}
     \Edges($v_1$,$v_2$,$v_4$,$v_3$,$v_1$)
     \Loop[dist=2cm,dir=EA,style={thick}]($v_3$) 
     \Edge[style={bend left}]($v_1$)($v_2$)
 \end{tikzpicture}
\end{document}

答案1

\Loop .. \Edge 線不編譯...

這是一種方法,但我不確定你想要實現什麼:

結果

\documentclass[border=10pt]{standalone}
\usepackage{tkz-graph}
\usetikzlibrary{calc} 
\GraphInit[vstyle=normal]
        
\begin{document}

 \begin{tikzpicture}
    % ~~~ internal fonts in circles, see 4.3 \SetVertexMath ~~~
    %     so the vertex' name is v_1, AND it's text is $v_1$
    %     we only need the names here
    \SetVertexMath      
    
    % ~~~ putting the vertices, see 2.1 \Vertex ~~~~
    \Vertex[x=0,y=0]{v_1}
    \Vertex[x=3,y=0]{v_2}
    \Vertex[x=0,y=3]{v_4}
    \Vertex[x=3,y=3]{v_3}
    
    % ~~~ multiple edge-connections, see 5.3 Multiple arêtes \Edges ~~~~~~~
    \Edges(v_4,v_1,v_2,v_4,v_3,v_1)
    
    \Edge[label=hi world](v_3)(v_2)     
    
    % ~~~ some loops, see5.2.1 Exemple avec \Loop ~~~~
    \Loop(v_4)                      % using defaults
    \Loop[dist=1cm, dir=EA](v_3)    % narrow, EAst=right side
    \Loop[dist=17mm, dir=SOWE,label=loop-1,style=left](v_1)
        
 \end{tikzpicture}

\end{document}

PS:讓我們稍微修改一下 v1 循環:

    \Loop[dist=17mm, dir=SOWE,label={loop-1},style={red,dashed,left,<->},labelstyle=teal](v_1)

結果2

相關內容