1

I am struggling to draw a graph on 2 vertices where the two big vertices are connected by a white edge. I have two issues:

  1. the gap: the edge meets my vertices at a tangent rather than fitting snugly against/under it
  2. white edge: white edges don't show up on white backgrounds; however, I would like the edge to appear with a clearly visible (somewhat thick) black border

My code snippet:

\begin{tikzpicture}
    \node [circle, fill=white, draw=black, minimum size = 1cm] (v2) at (-4,1) {};
    \node [circle, fill=white, draw=black, minimum size = 1cm] (v1) at (-7,5) {};
    \draw [line width = 1cm,draw=gray]  (v1) edge (v2);
\end{tikzpicture}

is a bit of an exaggeration, but hopefully it illustrates my first issue. This would look pretty sloppy in a paper or a talk.

I am at a loss for problem (2). Am I wrong to use tikz edges to draw/fill edges like vertices/nodes? What should I be using instead?

Thank you for your time!

1 Answer 1

2

You can achieve these outcomes by drawing the connections on the background layer between the node centers, and by using a double line.

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{backgrounds}
\begin{document}
\begin{tikzpicture}
  \begin{scope}
    \node [circle, fill=white, draw=black, minimum size = 1cm] (v2) at (-4,1) {};
    \node [circle, fill=white, draw=black, minimum size = 1cm] (v1) at (-7,5) {};
    \scoped[on background layer]{
    \draw [line width = 1cm,draw=gray]  (v1.center) -- (v2.center);}
  \end{scope}   
  \begin{scope}[xshift=4cm]
    \node [circle, fill=white, draw=black, minimum size = 1cm] (v2) at (-4,1) {};
    \node [circle, fill=white, draw=black, minimum size = 1cm] (v1) at (-7,5) {};
    \scoped[on background layer]{
    \draw [double distance=6mm,thin]  (v1.center) -- (v2.center);}
  \end{scope}   
\end{tikzpicture}
\end{document}

enter image description here

1
  • Wow. I think this is slick and perfectly solves my problem. You're awesome. Commented Apr 17, 2020 at 20:30

You must log in to answer this question.

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