1

Im trying to create this graph in latex, using tikzpicture:

enter image description here

This is my code so far:

\usepackage{tikz}
\begin{tikzpicture}[node distance={15mm}, thick, main/.style = {draw, circle}] 
\node[main] (1) {$_{1,1}$ }; 
\node[main] (2) [below right of=1] {$_{2,1}$ }; 
\node[main] (3) [above right of=2]  {$_{1,2}$ }; 
\node[main] (4) [below right of=3]  {$_{2,2}$ }; 
\draw (1) to [out=45, in=135] (3);
\draw (1) to [out=135,in=45] (3);
\draw (1) to (2); 
\draw (1) to [out=193,in=59,looseness=4] (4);
\draw (2) to (3); 
\draw (2) to [out=180+45, in=135+180] (4);
\draw (2) to [out=180+135,in=180+45] (4);
\draw (3) to (4); 
\end{tikzpicture} 

But this is not exactly what im trying to create. enter image description here

How can I add an edge that does not cross any existing edges or how can I adjust the direction of the curve or otherwise create the first graph?

Note: The initial positions of the edges should be preserved, the edge of 1,1 starting at the bottom left leads to 2,2 at the top right.

2
  • You'll get much better results by changing the line from (1) to (4) to use out=163, in=59, looseness=2. But honestly I'm not sure I understand your question and what you're asking specifically.
    – Skillmon
    Dec 8, 2021 at 13:25
  • @Hans Is the sentence is correct: the edge of 1,1 starting at the bottom left leads to 2,2 at the top right.
    – mmr
    Dec 8, 2021 at 13:36

2 Answers 2

1

I think your problem should be handled by using controls operation.

Here is a solution:

\documentclass{article}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[node distance={15mm}, thick, main/.style = {draw, circle}] 
\node[main] (1) {$_{1,1}$ }; 
\node[main] (2) [below right of=1] {$_{2,1}$ }; 
\node[main] (3) [above right of=2]  {$_{1,2}$ }; 
\node[main] (4) [below right of=3]  {$_{2,2}$ }; 
\draw (1) to [out=45, in=135] (3);
\draw (1) to [out=135,in=45] (3);
\draw (1) to (2); 
\draw (-.32,-.2) .. controls(-2.1,1.5) and (5.4,2) .. (3.45,-.8);
\draw (2) to (3); 
\draw (2) to [out=180+45, in=135+180] (4);
\draw (2) to [out=180+135,in=180+45] (4);
\draw (3) to (4); 
\end{tikzpicture} 

\end{document}

Output:

enter image description here

You can easily move the points as your need in the line accordingly. \draw (-.32,-.2) .. controls(-2.1,1.5) and (5.4,2) .. (3.45,-.8); where starting point is (-.32,-.2) and end point is (3.45,-.8). This points (-2.1,1.5) and (5.4,2) controls the shape of the curved line.

2

No need to invoke controls here (but it's a nice solution). Just play with the angle from where your edge starts. Here I just used \draw (1.-160) to... and played with the out value. Also, I added outer sep=0 pt to your node definition.

graph with edge at different angle

\documentclass[tikz]{standalone}

\begin{document}

    \begin{tikzpicture}[node distance={15mm}, thick, main/.style = {draw, circle,outer sep=0pt}] 
        \node[main] (1) {$_{1,1}$ }; 
        \node[main] (2) [below right of=1] {$_{2,1}$ }; 
        \node[main] (3) [above right of=2]  {$_{1,2}$ }; 
        \node[main] (4) [below right of=3]  {$_{2,2}$ }; 
        \draw (1) to [out=45, in=135] (3);
        \draw (1) to [out=135,in=45] (3);
        \draw (1) to (2); 
        \draw (1.-160) to [out=140,in=59,looseness=2] (4); % <------ HERE
        \draw (2) to (3); 
        \draw (2) to [out=180+45, in=135+180] (4);
        \draw (2) to [out=180+135,in=180+45] (4);
        \draw (3) to (4); 
    \end{tikzpicture}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .