我正在尝试使用 TikZ 绘制一些带有循环的无向图,但遇到了一些问题。
我的设置是
\documentclass[11pt]{article}
\usepackage{float}
\usepackage{tikz}
\tikzset{every loop/.style={}}
\begin{document}
\begin{figure}[H]
\centering
\begin{tikzpicture}
\begin{scope}
\node (0) at (0,0) {(0,0)};
\node (1) at (3,0) {(0,1)};
\node (2) at (0,-4) {(1,0)};
\node (3) at (3,-4) {(1,1)};
\end{scope}
\begin{scope}[every edge/.style={draw=black,thick}]
\path [-] (0) edge (1);
\path [-] (0) edge (2);
\path [-] (1) edge (3);
\path [-] (1) edge (2);
\path [-] (0) edge (3);
\path [-] (2) edge (3);
\path [-] (0) edge[loop] (0);
\path [-] (1) edge[loop] (1);
\path [-] (2) edge[loop] (2);
\path [-] (3) edge[loop] (3);
\end{scope}
\end{tikzpicture}
\caption{Graph $I_1 \times I_1$} \label{$I_1 \times I_1$}
\end{figure}
\end{document}
这里的问题是,我希望底部的环以某种方式移动,使其不与任何其他边缘相交。该怎么做?
感谢您的帮助!
答案1
经过多次尝试,我删除了循环%\tikzset{every loop/.style={}}
,并使用参数修复了每个循环边缘的循环loop,in=60,out=120,looseness=10
。这些是我使用 Papeeria(用于编译的 TeX 引擎编辑器LaTeX
)进行多次编译后选择的。我希望循环很好。如果它们不是很好,您可以更改的值loop,in=...,out=...,looseness=...
。
\documentclass[11pt]{article}
\usepackage{float}
\usepackage{amsmath,amssymb}
\usepackage{tikz}
%\tikzset{every loop/.style={}}
\begin{document}
\begin{figure}[H]
\centering
\begin{tikzpicture}
\begin{scope}
\node (0) at (0,0) {(0,0)};
\node (1) at (3,0) {(0,1)};
\node (2) at (0,-4) {(1,0)};
\node (3) at (3,-4) {(1,1)};
\end{scope}
\begin{scope}[every edge/.style={draw=black,thick}]
\path [-] (0) edge (1);
\path [-] (0) edge (2);
\path [-] (1) edge (3);
\path [-] (1) edge (2);
\path [-] (0) edge (3);
\path [-] (2) edge (3);
\path [-] (0) edge[loop,in=60,out=120,looseness=10] (0);
\path [-] (1) edge[loop,in=60,out=120,looseness=10] (1);
\path [-] (2) edge[loop,in=-60,out=240,looseness=10] (2);
\path [-] (3) edge[loop,in=-60,out=240,looseness=10] (3);
\end{scope}
\end{tikzpicture}
%\caption{Graph $I_1 \times I_1$} \label{I_1 \times I_1}
\end{figure}
\end{document}
这是我的原始代码,带有一些小循环:
\documentclass[11pt]{article}
\usepackage{float}
\usepackage{amsmath,amssymb}
\usepackage{tikz}
\tikzset{every loop/.style={}}
\begin{document}
\begin{figure}[H]
\centering
\begin{tikzpicture}
\begin{scope}
\node (0) at (0,0) {(0,0)};
\node (1) at (3,0) {(0,1)};
\node (2) at (0,-4) {(1,0)};
\node (3) at (3,-4) {(1,1)};
\end{scope}
\begin{scope}[every edge/.style={draw=black,thick}]
\path [-] (0) edge (1);
\path [-] (0) edge (2);
\path [-] (1) edge (3);
\path [-] (1) edge (2);
\path [-] (0) edge (3);
\path [-] (2) edge (3);
\path [-] (0) edge[loop above] (0);
\path [-] (1) edge[loop above] (1);
\path [-] (2) edge[loop below] (2);
\path [-] (3) edge[loop below] (3);
\end{scope}
\end{tikzpicture}
%\caption{Graph $I_1 \times I_1$} \label{I_1 \times I_1}
\end{figure}
\end{document}