Skip to content

Instantly share code, notes, and snippets.

@sailik1991
Last active June 28, 2020 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sailik1991/8613b4e9dbf01927f11ad7d6d3023b19 to your computer and use it in GitHub Desktop.
Save sailik1991/8613b4e9dbf01927f11ad7d6d3023b19 to your computer and use it in GitHub Desktop.
tikz-stuff

Generates a bipartite graph with vertex sets V1 an V2 and edge list E

\begin{figure}[t]
\centering
\begin{tikzpicture}
% V1
\foreach \i in {-2, -1, ..., 2} {
    \node at (\i, 0) (v\i) {$v_{\i}$};
    \fill (\i, -0.25) circle (1.5pt);
}

% V2
\foreach \i in {-5, -4.75, ..., 5} {
    \fill (\i, -2) circle (1.5pt);
}

% Edges
\foreach \u/\v in {1/14,1/15,1/16,1/17,1/18,1/27,1/28,1/29,1/8,1/9,1/10,1/11,1/12,1/13,1/19,1/20,1/21,1/22,1/30,1/31,1/32,1/33,1/34,2/14,2/15,2/16,2/17,2/18,2/31,2/32,2/33,2/34,2/8,2/9,2/10,2/11,2/12,2/13,2/19,2/20,2/21,2/22,2/27,2/28,2/29,2/35,2/36,2/44,2/45,3/19,3/20,3/21,3/22,3/23,3/24,3/25,3/26,3/6,3/7,3/8,3/9,3/10,3/11,3/14,3/15,3/16,3/17,3/18,3/37,3/38,3/39,3/40,3/41,3/42,3/43,4/27,4/28,4/29,4/30,4/14,4/15,4/16,4/17,4/18,4/31,4/32,4/33,4/34,5/27,5/28,5/29,5/31,5/32,5/33,5/34,5/14,5/15,5/16,5/17,5/18,5/30,5/35,5/36,5/44,5/45}{
    \draw (\u - 3, -0.3)--(\v / 4 - 6.5, -2);
}

\node at (-5.9, 0) {$V_1=$};
\node at (-5.9, -2) {$V_2=$};
\end{tikzpicture}
\end{figure}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment