2

I'm trying to draw some undirected graphs with loops using TikZ, but running into some problem.

My set up is

\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}

This produces enter image description here

The problem here is that I want the loop at the bottom to somehow move that it doesn't intersect with any other edges. How would one do that?

Thanks for your help!

2
  • 2
    edge[loop below]? – Henri Menke Jul 1 '20 at 21:34
  • @HenriMenke Hi, I had tried before of you comment but the problem is \tikzset{every loop/.style={}} where every loop are little. – Sebastiano Jul 1 '20 at 22:05
3

After many attemps I have deleted %\tikzset{every loop/.style={}} and I have fixed the loop for every loop edge using the parameters loop,in=60,out=120,looseness=10. These are chosen after many compilations for me using Papeeria (a TeX engine editor to compile in LaTeX). I hope that the loop are good. If they are not very good you can change the values of 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}

enter image description here


This is my original code with little loops:

\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} 

enter image description here

7
  • 1
    Thanks so much! – Phil Jul 1 '20 at 22:12
  • @Phil I'm glady to help you...at this moment I not remember how I can delete your mistake of the caption. I'm sorry. – Sebastiano Jul 1 '20 at 22:14
  • 2
    @Sebastiano The problem is not the caption but the label. Try instead \label{I_1 times I_1}. – Henri Menke Jul 1 '20 at 22:43
  • @HenriMenke Ok and thank you very very much. – Sebastiano Jul 1 '20 at 22:48
  • 2
    @Sebastiano Wrong, the $ are actually fine. It's \times that trips up the label. – Henri Menke Jul 2 '20 at 3:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.