5

I would like to draw simple graphs in latex with tikz.

My figure that I would like to produce looks like this and I would like to put it in beamer.enter image description here

2
  • Welcome to TeX.SX! Do you have some ideas about it to share or are you just stumped from the beginning?
    – egreg
    Commented May 11, 2015 at 21:53
  • What are bipartite graphs? I'm afraid they just look like squiggles to me, but I'm sure there's more to it than that.
    – cfr
    Commented May 11, 2015 at 22:04

1 Answer 1

4

I define some building blocks and then use tikzcd for typesetting the blocks:

\documentclass{article}
\usepackage{tikz-cd}

\newcommand{\pairsolid}{\bullet \arrow[r] \& \bullet}
\newcommand{\pairdashed}{\bullet \arrow[r,dashed] \& \bullet}

\begin{document}
\[
\begin{tikzcd}[nodes={inner sep=-1pt},arrows=-,ampersand replacement=\&]
\pairdashed \& \pairsolid  \& \pairsolid  \& \pairdashed \\
\pairsolid  \& \pairdashed \& \pairsolid  \& \pairsolid  \\
\pairdashed \& \pairdashed \& \pairdashed \& \pairdashed
\end{tikzcd}
\]
\end{document}

enter image description here

You can reduce the distances:

\documentclass{article}
\usepackage{tikz-cd}

\newcommand{\pairsolid}{\bullet \arrow[r] \& \bullet}
\newcommand{\pairdashed}{\bullet \arrow[r,dashed] \& \bullet}

\begin{document}
\[
\begin{tikzcd}[
  nodes={inner sep=-1pt},
  arrows=-,
  ampersand replacement=\&,
  row sep=1ex,
  column sep=1.2em,
]
\pairdashed \& \pairsolid  \& \pairsolid  \& \pairdashed \\
\pairsolid  \& \pairdashed \& \pairsolid  \& \pairsolid  \\
\pairdashed \& \pairdashed \& \pairdashed \& \pairdashed
\end{tikzcd}
\]
\end{document}

enter image description here

2
  • Is there a way to reduce the size of the graph? Or make the length of the arrow small?
    – Kira
    Commented May 12, 2015 at 15:13
  • @Kira Yes, of course. Reduce column sep and row sep.
    – egreg
    Commented May 12, 2015 at 15:32

You must log in to answer this question.

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