1

How do I draw this tripartite 3 uniform hypergraph using TikZ? Thank you.

tripartite 3 uniform hypergraph

5
  • 1
    Welcome to TeX.SX! Questions about how to draw specific graphics that just post an image of the desired result are really not reasonable questions to ask on the site. Please post a minimal compilable document showing that you've tried to produce the image and then people will be happy to help you with any specific problems you may have. See minimal working example (MWE) for what needs to go into such a document. Apr 4, 2021 at 6:36
  • Usually, I would say use the fit library, to fit the nodes with triangles, but I already tried it and it does not work as aspected. Your way could be using the idea of tex.stackexchange.com/questions/335811/… for the ellipses of the respective 3 points for R, L, and C and then do either something like this answer tex.stackexchange.com/questions/468950/… or this answer tex.stackexchange.com/questions/517621/… for the triangles.
    – Excelsior
    Apr 13, 2021 at 15:08
  • This is perfect since I tried to draw the edges using a triangle, however that would give me trouble when I started to color the edges.
    – Iras
    Apr 16, 2021 at 2:50
  • @Iras I changed my second example slightly, that it fits better to your question.
    – Excelsior
    Apr 16, 2021 at 10:29
  • @Excelsior I used your first code to make more edges between each partite of the graph since it is easier for me to shift the edges by adjusting the coordinates and give them a different color so. If I fix the coordinate for the edges, then the color will eventually get mixed at some point and I do not want that since I am trying to show that it is a 1-factorization. Thank you again!!
    – Iras
    Apr 18, 2021 at 20:30

1 Answer 1

1

Like mentioned in the comments, I suggest the workflow from this answer, since it is close to what you want to achieve.

enter image description here

\documentclass[border=5pt]{standalone}

\usepackage{tikz}
\usetikzlibrary{fit, backgrounds, shapes, calc}

\definecolor{mypink}{RGB}{222,136,165}
\definecolor{myred}{RGB}{194,100,118}
\definecolor{myblue}{RGB}{177,235,255}
\definecolor{mygreen}{RGB}{90,155,123}
\definecolor{myyellow}{RGB}{255,220,116}
\definecolor{mybrown}{RGB}{182,152,142}
\definecolor{myviolett}{RGB}{91,60,117}

\begin{document}
    \begin{tikzpicture}
        
        % draw nodes
        
        \draw[fill=black] (0,0) circle[radius=2.5pt] node(L1)  {};
        \draw[fill=black] ($(L1) + (1,0)$) circle[radius=2.5pt] node(L2) {};
        \draw[fill=black] ($(L2) + (1,0)$) circle[radius=2.5pt] node(L3) {};
        
        \draw[fill=black] ($(L1) + (-3,5)$) circle[radius=2.5pt] node(R1) {};
        \draw[fill=black] ($(R1) + (0.5,0.5)$) circle[radius=2.5pt] node(R2) {};
        \draw[fill=black] ($(R2) + (0.5,0.5)$) circle[radius=2.5pt] node(R3) {};
        
        \draw[fill=black] ($(L3) + (3,5)$) circle[radius=2.5pt] node(C1) {};
        \draw[fill=black] ($(C1) + (-0.5,0.5)$) circle[radius=2.5pt] node(C2) {};
        \draw[fill=black] ($(C2) + (-0.5,0.5)$) circle[radius=2.5pt] node(C3) {};
        
        % add labels
        
        \node[below=5pt, font=\footnotesize] at (L1) {1};
        \node[below=5pt, font=\footnotesize] at (L2) {2};
        \node[below=15pt] at (L2) {\textbf{L}};
        \node[below=5pt, font=\footnotesize] at (L3) {3};
        
        \node[above left=2.5pt, font=\footnotesize] at (R1) {1};
        \node[above left=2.5pt, font=\footnotesize] at (R2) {2};
        \node[above left=10pt] at (R2) {\textbf{R}};
        \node[above left=2.5pt, font=\footnotesize] at (R3) {3};
                
        \node[above right=2.5pt, font=\footnotesize] at (C1) {1};
        \node[above right=2.5pt, font=\footnotesize] at (C2) {2};
        \node[above right=10pt] at (C2) {\textbf{C}};
        \node[above right=2.5pt, font=\footnotesize] at (C3) {3};
            
        % fill elements
            
        \node[fit=(L1)(L3), ellipse, draw=black, inner xsep=-4pt, inner ysep=2pt] {};
        \node[fit=(R1)(R3), ellipse, draw=black, inner xsep=-12pt, rotate=-45] {};
        \node[fit=(C1)(C3), ellipse, draw=black, inner xsep=-12pt, rotate=45] {};
        
        \begin{pgfonlayer}{background}
            
            \draw[rounded corners=20pt, myblue] ([xshift=-7.5pt,yshift=7.5pt]R3.north west) -- ([xshift=0pt,yshift=-10pt]L1.south west) -- ([xshift=10pt,yshift=2.5pt]C1.north east) -- cycle;
            
        \end{pgfonlayer}
    
    \end{tikzpicture}
\end{document}

Since your drawing is quite confusing, I cannot finish it, so I made a start for you, where you can work on further.

EDIT

I found an, in my eays, better way to do it using this answer with the drawback that you have to define the triangles twice.

\documentclass[border=5pt]{standalone}

\usepackage{tikz}
\usetikzlibrary{fit, backgrounds, shapes, calc}

\definecolor{mypink}{RGB}{222,136,165}
\definecolor{myred}{RGB}{194,100,118}
\definecolor{myblue}{RGB}{177,235,255}
\definecolor{mygreen}{RGB}{90,155,123}
\definecolor{myyellow}{RGB}{255,220,116}
\definecolor{mybrown}{RGB}{182,152,142}
\definecolor{myviolett}{RGB}{91,60,117}

\begin{document}
    \begin{tikzpicture}
        
        \def\linewidtha{0.5mm}
        \def\linewidthb{6mm}
        \tikzstyle{inner triangle} = [line width=\linewidthb,rounded corners=10pt]
        \tikzstyle{outer triangle} = [line width=\linewidthb+\linewidtha,rounded corners=10pt]
        
        % draw nodes
        
        \draw[fill=black] (0,0) circle[radius=2.5pt] node(L1)  {};
        \draw[fill=black] ($(L1) + (1,0)$) circle[radius=2.5pt] node(L2) {};
        \draw[fill=black] ($(L2) + (1,0)$) circle[radius=2.5pt] node(L3) {};
        
        \draw[fill=black] ($(L1) + (-3,5)$) circle[radius=2.5pt] node(R1) {};
        \draw[fill=black] ($(R1) + (0.5,0.5)$) circle[radius=2.5pt] node(R2) {};
        \draw[fill=black] ($(R2) + (0.5,0.5)$) circle[radius=2.5pt] node(R3) {};
        
        \draw[fill=black] ($(L3) + (3,5)$) circle[radius=2.5pt] node(C1) {};
        \draw[fill=black] ($(C1) + (-0.5,0.5)$) circle[radius=2.5pt] node(C2) {};
        \draw[fill=black] ($(C2) + (-0.5,0.5)$) circle[radius=2.5pt] node(C3) {};
        
        % add labels
        
        \node[below=5pt, font=\footnotesize] at (L1) {1};
        \node[below=5pt, font=\footnotesize] at (L2) {2};
        \node[below=15pt] at (L2) {\textbf{L}};
        \node[below=5pt, font=\footnotesize] at (L3) {3};
        
        \node[above left=2.5pt, font=\footnotesize] at (R1) {1};
        \node[above left=2.5pt, font=\footnotesize] at (R2) {2};
        \node[above left=10pt] at (R2) {\textbf{R}};
        \node[above left=2.5pt, font=\footnotesize] at (R3) {3};
        
        \node[above right=2.5pt, font=\footnotesize] at (C1) {1};
        \node[above right=2.5pt, font=\footnotesize] at (C2) {2};
        \node[above right=10pt] at (C2) {\textbf{C}};
        \node[above right=2.5pt, font=\footnotesize] at (C3) {3};
        
        % fill elements
        
        \node[fit=(L1)(L3), ellipse, draw=black, inner xsep=-4pt, inner ysep=2pt] {};
        \node[fit=(R1)(R3), ellipse, draw=black, inner xsep=-12pt, rotate=-45] {};
        \node[fit=(C1)(C3), ellipse, draw=black, inner xsep=-12pt, rotate=45] {};
        
        \begin{pgfonlayer}{background}
            
            \draw[outer triangle, myblue]
            (R3.center)  -- (L1.center) -- (C1.center) -- cycle;
            \filldraw[inner triangle, white]
            (R3.center)  -- (L1.center) -- (C1.center) -- cycle;
            
        \end{pgfonlayer}
        
    \end{tikzpicture}
\end{document}

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