Draw double line with empty interior in TikZ

By playing around with transparency group one can create the desired effect:

\documentclass[12pt]{article}
\usepackage{tikz}

\begin{document}
\begin{figure}[!htbp]
\centering
\begin{tikzpicture}[scale=4,
    vertex/.style={draw,circle,minimum size=0.75cm,inner sep=0pt},
    arc/.style={draw=blue!50,thick,->},
    arc label/.style={fill=white,font=\tiny,inner sep=1pt},
    loop arc/.style={min distance=2mm}
    ]

\pgfsetblendmode{multiply}    

\begin{scope}[transparency group]    
% Subset 1
\draw[double=none, double distance=60pt, line join=round, line cap=round, draw=black] (1,0)--(0.3090,0.9511)--(-0.8090,0.5878);
\end{scope}

\begin{scope}[transparency group]
% Subset 2
\draw[double=none, double distance=60pt, line join=round, line cap=round, draw=red] (-0.8090,0.5878)--(-0.8090,-0.5878)--(0.3090,-0.9511);
\end{scope}
\end{tikzpicture}
\end{figure}

\end{document}

enter image description here


\documentclass[12pt]{article}
\usepackage{tikz}

\begin{document}
\begin{figure}[!htbp]
\centering
\begin{tikzpicture}[scale=4,
    vertex/.style={draw,circle,minimum size=0.75cm,inner sep=0pt},
    arc/.style={draw=blue!50,thick,->},
    arc label/.style={fill=white,font=\tiny,inner sep=1pt},
    loop arc/.style={min distance=2mm}
    ]

\pgfsetblendmode{multiply}

\begin{scope}[transparency group]
\draw[line width=60pt, line join=round, line cap=round, draw=red] (-0.8090,0.5878)--(-0.8090,-0.5878)--(0.3090,-0.9511);
\draw[line width=40pt, line join=round, line cap=round, draw=white] (-0.8090,0.5878)--(-0.8090,-0.5878)--(0.3090,-0.9511);
\draw[line width=60pt, line join=round, line cap=round, draw=black] (1,0)--(0.3090,0.9511)--(-0.8090,0.5878);
\draw[line width=40pt, line join=round, line cap=round, draw=white] (1,0)--(0.3090,0.9511)--(-0.8090,0.5878);
\end{scope}

\begin{scope}[transparency group]
\draw[line width=60pt, line join=round, line cap=round, draw=black] (1,0)--(0.3090,0.9511)--(-0.8090,0.5878);
\draw[line width=40pt, line join=round, line cap=round, draw=white] (1,0)--(0.3090,0.9511)--(-0.8090,0.5878);
\draw[line width=60pt, line join=round, line cap=round, draw=red] (-0.8090,0.5878)--(-0.8090,-0.5878)--(0.3090,-0.9511);
\draw[line width=40pt, line join=round, line cap=round, draw=white] (-0.8090,0.5878)--(-0.8090,-0.5878)--(0.3090,-0.9511);
\end{scope}

\end{tikzpicture}
\end{figure}

\end{document}

enter image description here


This is what I was trying to achieve originally, with a graph on the top layer as follows,

\documentclass[12pt]{article}
\usepackage{tikz}
\usepackage{ifthen}

% Weighted graph from adjacency matrix
\newcommand{\weigthedgraphfromadj}[6][draw,->]{
    \foreach [count=\r] \row in {#3}{
        \foreach [count=\c] \cell in \row{
            \ifnum\cell>0
                \ifnum\c=\r
                    \draw[arc/.try=\cell] (#2\r) edge[loop arc, in= #4*\r -#5 -#4*#6, out= #4*\r +#5 -#4*#6] node[arc label/.try=\cell]{\cell} (#2\c);
                \else
                    \draw[arc/.try=\cell, #1] (#2\r) edge node[arc label/.try=\cell]{\cell} (#2\c);
                \fi
            \fi
        }
    }
}

\begin{document}
\begin{figure}[!htbp]
\centering
\begin{tikzpicture}[scale=4,
    vertex/.style={draw,circle,minimum size=0.75cm,inner sep=0pt},
    arc/.style={draw=blue!50,thick,->},
    arc label/.style={fill=white,font=\tiny,inner sep=1pt},
    loop arc/.style={min distance=2mm}
    ]

\pgfsetblendmode{multiply}    
\begin{scope}[transparency group]    
% Subset 1
\draw[double=none, double distance=60pt, line join=round, line cap=round, draw=black] (1,0)--(0.3090,0.9511)--(-0.8090,0.5878);
\end{scope}

\begin{scope}[transparency group]
% Subset 2
\draw[double=none, double distance=60pt, line join=round, line cap=round, draw=red] (-0.8090,0.5878)--(-0.8090,-0.5878)--(0.3090,-0.9511);
\end{scope}
\pgfsetblendmode{normal}
    \foreach [count=\i] \coord in
                        {(0.3090,0.9511),
                        (-0.8090,0.5878),
                        (-0.8090,-0.5878),
                        (0.3090,-0.9511),
                        (1,0)}
                        {
        \ifthenelse{\i<4}{\node[vertex] (p\i) at \coord {$x_{\i}$}}{\ifthenelse{\i=4}{\node[vertex] (p\i) at \coord {$u_{2}$}}{\node[vertex] (p\i) at \coord {$u_{1}$}}};
    }
    \weigthedgraphfromadj[bend left=10]{p}{{1,1,1,0,0},
                                            {24,20,24,0,0},
                                            {1,1,1,0,0},
                                            {0,0,2,0,0},
                                            {2,0,0,0,0}}{72}{30}{0}
\end{tikzpicture}
\end{figure}

\end{document}

There is a graph macro plotting graphs from some coordinates and an adjacency matrix. The sets are overlapping weighted directed subgraphs.

Hope it can be of some use for others.

Romain

enter image description here

Tags:

Tikz Pgf