Last active
November 28, 2024 03:58
-
-
Save michaeldorner/feccd5bfe6314546881e1a4afcc76fb5 to your computer and use it in GitHub Desktop.
hypergraphs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass{minimal} | |
\usepackage{tikz} | |
\usepackage{tikz-network} | |
\usetikzlibrary{calc, backgrounds, positioning} | |
\input{tikz-hypergraph} | |
\usepackage{xcolor} | |
\definecolor{ACMYellow}{RGB}{255, 214, 0} | |
\definecolor{ACMOrange}{RGB}{252, 146, 0} | |
\definecolor{ACMRed}{RGB}{253, 27, 20} | |
\definecolor{ACMLightBlue}{RGB}{131, 206, 226} | |
\definecolor{ACMGreen}{RGB}{166, 188, 9} | |
\definecolor{ACMPurple}{RGB}{101, 1, 107} | |
\definecolor{ACMDarkBlue}{RGB}{9, 53, 122} | |
\begin{document} | |
\begin{tikzpicture} | |
\tikzstyle{important}=[draw, circle, minimum size=8mm, fill=white]; | |
\tikzstyle{unimportant}=[draw, circle, minimum size=4mm, fill=white]; | |
\node at (0,1) (v1) {}; | |
\node at (2,1.75) (v2) {}; | |
\node at (2,0) (v3) {}; | |
\node at (4,3) (v4) {}; | |
\node at (4,0) (v5) {}; | |
\node at (6,1) (v6) {}; | |
\node at (4.55,-1.5) (v7) {}; | |
\node at (0.75,2) (v8) {}; | |
\node at (2.5,3.5) (v9) {}; | |
\draw[draw, fill=ACMDarkBlue, fill opacity=0.5] \hedgem{v1}{v8}{v2,v3}{6mm}; | |
\draw[draw, fill=ACMRed, fill opacity=0.5] \hedgem{v2}{v9}{v4}{6mm}; | |
\draw[draw, fill=ACMPurple, fill opacity=0.5] \hedgem{v5}{v4}{v6}{6mm}; | |
\draw[draw, fill=ACMOrange, fill opacity=0.5] \hedgem{v3}{v6}{v7}{6mm}; | |
\node[important] at (v1) {$v_1$}; | |
\node[important] at (v2) {$v_2$}; | |
\node[important] at (v3) {$v_3$}; | |
\node[important] at (v4) {$v_4$}; | |
\node[important] at (v5) {$v_5$}; | |
\node[important] at (v6) {$v_6$}; | |
\node[unimportant] at (v7) {}; | |
\node[unimportant] at (v8) {}; | |
\node[unimportant] at (v9) {}; | |
\node at (1, 1) {$e_1$}; | |
\node at (2.75, 2.75) {$e_2$}; | |
\node at (3.5, -1) {$e_3$}; | |
\node at (4.75, 2) {$e_4$}; | |
\end{tikzpicture} | |
\end{document} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Needs | |
% \usetikzlibrary{calc} | |
% \usepackage{ifthen} | |
\def\rotateclockwise#1{ | |
% Rotate input point by 90 degrees clockwise. | |
\newdimen\xrw | |
\pgfextractx{\xrw}{#1} | |
\newdimen\yrw | |
\pgfextracty{\yrw}{#1} | |
% \pgfpoint{-\y}{\x} | |
\pgfpoint{\yrw}{-\xrw} | |
} | |
\def\rotatecounterclockwise#1{ | |
% Rotate input point by 90 degrees clockwise. | |
\newdimen\xrcw | |
\pgfextractx{\xrcw}{#1} | |
\newdimen\yrcw | |
\pgfextracty{\yrcw}{#1} | |
% \pgfpoint{-\y}{\x} | |
\pgfpoint{-\yrcw}{\xrcw} | |
} | |
\def\outsidespacerpgfclockwise#1#2#3{ | |
% #1 start point | |
% #2 end point | |
% #3 radius | |
% Compute a length-radius vector perpendicular (clockwise) | |
% to the vector from start point to end point. | |
\pgfpointscale{#3}{ | |
\rotateclockwise{ | |
\pgfpointnormalised{ | |
\pgfpointdiff{#1}{#2}}}} | |
} | |
\def\outsidespacerpgfcounterclockwise#1#2#3{ | |
% #1 start point | |
% #2 end point | |
% #3 radius | |
% Compute a length-radius vector perpendicular (counterclockwise) | |
% to the line from start point to end point. | |
\pgfpointscale{#3}{ | |
\rotatecounterclockwise{ | |
\pgfpointnormalised{ | |
\pgfpointdiff{#1}{#2}}}} | |
} | |
\def\outsidepgfclockwise#1#2#3{ | |
% #1 start point | |
% #2 end point | |
% #3 radius | |
% Add to end point a length-radius vector perpendicular | |
% (counter-clockwise) to the line from start point to end point. | |
\pgfpointadd{#2}{\outsidespacerpgfclockwise{#1}{#2}{#3}} | |
} | |
\def\outsidepgfcounterclockwise#1#2#3{ | |
% #1 start point | |
% #2 end point | |
% #3 radius | |
% Add to end point a length-radius vector perpendicular | |
% (counter-clockwise) to the line from start point to end point. | |
\pgfpointadd{#2}{\outsidespacerpgfcounterclockwise{#1}{#2}{#3}} | |
} | |
\def\outside#1#2#3{ | |
($ (#2) ! #3 ! -90 : (#1) $) | |
} | |
\def\cornerpgf#1#2#3#4{ | |
% #1 = previous pgf point | |
% #2 = current pgf point | |
% #3 = next pgf point | |
% #4 = radius | |
% Computes a path comprising a rounded corner on the outside of the angle #1#2#3. | |
\pgfextra{ | |
\pgfmathanglebetweenpoints{#2}{\outsidepgfcounterclockwise{#1}{#2}{#4}} | |
\let\anglea\pgfmathresult | |
\let\startangle\pgfmathresult | |
\pgfmathanglebetweenpoints{#2}{\outsidepgfclockwise{#3}{#2}{#4}} | |
\pgfmathparse{\pgfmathresult - \anglea} | |
\pgfmathroundto{\pgfmathresult} | |
\let\arcangle\pgfmathresult | |
\ifthenelse{180=\arcangle \or 180<\arcangle}{ | |
\pgfmathparse{-360 + \arcangle}}{ | |
\pgfmathparse{\arcangle}} | |
\let\deltaangle\pgfmathresult | |
\newdimen\x | |
\pgfextractx{\x}{\outsidepgfcounterclockwise{#1}{#2}{#4}} | |
\newdimen\y | |
\pgfextracty{\y}{\outsidepgfcounterclockwise{#1}{#2}{#4}} | |
} | |
-- (\x,\y) arc [start angle=\startangle, delta angle=\deltaangle, radius=#4] | |
} | |
\def\corner#1#2#3#4{ | |
\cornerpgf{\pgfpointanchor{#1}{center}}{\pgfpointanchor{#2}{center}}{\pgfpointanchor{#3}{center}}{#4} | |
} | |
\def\hedgeiii#1#2#3#4{ | |
% #1#2#3 = tikz points | |
% #4 = radius | |
% Computes a path comprising the line of the points outside of the | |
% convex hull H of the points #1#2#3 that have distance #4 to H. | |
% Points #1#2#3 need to be in clockwise order. | |
\outside{#1}{#2}{#4} \corner{#1}{#2}{#3}{#4} \corner{#2}{#3}{#1}{#4} \corner{#3}{#1}{#2}{#4} -- cycle | |
} | |
\def\hedgem#1#2#3#4{ | |
% #1#2 = tikz points | |
% #3 = list of tikz points | |
% #4 = radius | |
% Computes a path comprising the line of the points outside of the convex hull H of the points #1#2[#3] that have distance #4 to H. | |
% Points #1#2[#3] need to be vertices of a convex polygon and in clockwise order. | |
\outside{#1}{#2}{#4} | |
\pgfextra{ | |
\def\hgnodea{#1} | |
\def\hgnodeb{#2} | |
} | |
foreach \c in {#3} { | |
\corner{\hgnodea}{\hgnodeb}{\c}{#4} | |
\pgfextra{ | |
\global\let\hgnodea\hgnodeb | |
\global\let\hgnodeb\c | |
} | |
} | |
\corner{\hgnodea}{\hgnodeb}{#1}{#4} | |
\corner{\hgnodeb}{#1}{#2}{#4} | |
-- cycle | |
} | |
\def\hedgeii#1#2#3{ | |
% #1#2 = tikz points | |
% #3 = radius | |
\hedgem{#1}{#2}{}{#3} | |
} | |
\def\hedgei#1#2{ | |
% #1 = tikz point | |
% #2 = radius | |
(#1) circle [radius = #2] | |
} |
Author
michaeldorner
commented
Nov 8, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment