[Tex/LaTex] How to draw the following graph with tikz

graphstikz-pgf

Some irregular curves and their surrounding shadows are all needed to draw a graph in graph theory. I'm not very good at drawing this with Tikz, but I want to do my best to draw the following graph.

Enter image description here

I used some code from Drawing Königsberg landscape showing the bridges and it seems that no good and concise. But I didn't draw it well enough, and the code wasn't clean enough.

\documentclass{article}
\usepackage{xcolor}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing, calc}
\definecolor{babypink}{rgb}{0.96, 0.76, 0.76}
\tikzset{%
    contour/.style={dashed,%
        very thick,%
        decoration={%
            random steps,%
            segment length=4pt,%
            amplitude=0.5pt%
        },%
        rounded corners=1pt,%
        decorate%
    }%
}

\begin{document}
    \begin{tikzpicture}[x=10cm, y=9.19cm]
        \filldraw[babypink] ($(0, 1) + (0.241, -0.622)$) -- ($(0, 1) + (0.235,
        -0.587)$)
        --
        ($(0, 1) + (0.240, -0.540)$) -- ($(0, 1) + (0.249, -0.524)$) --
        ($(0, 1) + (0.252, -0.498)$) -- ($(0, 1) + (0.266, -0.482)$) --
        ($(0, 1) + (0.271, -0.462)$) -- ($(0, 1) + (0.288, -0.454)$) --
        ($(0, 1) + (0.300, -0.434)$) -- ($(0, 1) + (0.308, -0.418)$) --
        ($(0, 1) + (0.320, -0.412)$) -- ($(0, 1) + (0.328, -0.404)$) --
        ($(0, 1) + (0.399, -0.399)$) -- ($(0, 1) + (0.453, -0.393)$) --
        ($(0, 1) + (0.518, -0.386)$) -- ($(0, 1) + (0.549, -0.388)$) --
        ($(0, 1) + (0.609, -0.404)$) -- ($(0, 1) + (0.624, -0.410)$) --
        ($(0, 1) + (0.644, -0.438)$) -- ($(0, 1) + (0.663, -0.486)$) --
        ($(0, 1) + (0.670, -0.519)$) -- ($(0, 1) + (0.668, -0.546)$) --
        ($(0, 1) + (0.658, -0.590)$) -- ($(0, 1) + (0.648, -0.612)$) --
        ($(0, 1) + (0.636, -0.648)$) -- ($(0, 1) + (0.633, -0.666)$) --
        ($(0, 1) + (0.617, -0.677)$) -- ($(0, 1) + (0.596, -0.700)$) --
        ($(0, 1) + (0.535, -0.708)$) -- ($(0, 1) + (0.500, -0.709)$) --
        ($(0, 1) + (0.457, -0.717)$) -- ($(0, 1) + (0.412, -0.708)$) --
        ($(0, 1) + (0.372, -0.702)$) -- ($(0, 1) + (0.336, -0.695)$) --
        ($(0, 1) + (0.291, -0.679)$) -- ($(0, 1) + (0.268, -0.652)$) --
        cycle;
        \draw[contour] ($(0, 1) + (0.241, -0.622)$) -- ($(0, 1) + (0.235, -0.587)$) --
        ($(0, 1) + (0.240, -0.540)$) -- ($(0, 1) + (0.249, -0.524)$) --
        ($(0, 1) + (0.252, -0.498)$) -- ($(0, 1) + (0.266, -0.482)$) --
        ($(0, 1) + (0.271, -0.462)$) -- ($(0, 1) + (0.288, -0.454)$) --
        ($(0, 1) + (0.300, -0.434)$) -- ($(0, 1) + (0.308, -0.418)$) --
        ($(0, 1) + (0.320, -0.412)$) -- ($(0, 1) + (0.328, -0.404)$) --
        ($(0, 1) + (0.399, -0.399)$) -- ($(0, 1) + (0.453, -0.393)$) --
        ($(0, 1) + (0.518, -0.386)$) -- ($(0, 1) + (0.549, -0.388)$) --
        ($(0, 1) + (0.609, -0.404)$) -- ($(0, 1) + (0.624, -0.410)$) --
        ($(0, 1) + (0.644, -0.438)$) -- ($(0, 1) + (0.663, -0.486)$) --
        ($(0, 1) + (0.670, -0.519)$) -- ($(0, 1) + (0.668, -0.546)$) --
        ($(0, 1) + (0.658, -0.590)$) -- ($(0, 1) + (0.648, -0.612)$) --
        ($(0, 1) + (0.636, -0.648)$) -- ($(0, 1) + (0.633, -0.666)$) --
        ($(0, 1) + (0.617, -0.677)$) -- ($(0, 1) + (0.596, -0.700)$) --
        ($(0, 1) + (0.535, -0.708)$) -- ($(0, 1) + (0.500, -0.709)$) --
        ($(0, 1) + (0.457, -0.717)$) -- ($(0, 1) + (0.412, -0.708)$) --
        ($(0, 1) + (0.372, -0.702)$) -- ($(0, 1) + (0.336, -0.695)$) --
        ($(0, 1) + (0.291, -0.679)$) -- ($(0, 1) + (0.268, -0.652)$) --
        ($(0, 1) + (0.241, -0.622)$);
    \node[draw,circle] (u) at ($(0, 1) + (0.5, -0.388)$)[label={$u$}]{};
 \node[draw,circle] (u2)  at ($(0, 1) + (0.658,
 -0.582)$)[label=right:{$u_2$}]{};
\node[draw,circle] (v) at ($(0, 1) + (0.5, -0.71)$)[label=below:{$v$}]{};
\node[draw,circle] (u1) at ($(0, 1) + (0.23, -0.582)$)[label=left:{$u_1$}]{};
\draw [in=-165, out=165, looseness=5.00](u) to (v);
\node[] at (0.5,0.5) {$f$};
\end{tikzpicture}
\end{document}

![Enter image description here

Holding a learning attitude, I‘d like to learn more concise tikz code which can draw the graph I want. For those irregular curves in the original graph, I don't know if there is any software that can assist in generating them.

Best Answer

That's a very painful way of drawing something like that. Unfortunately, the random steps command is not very easy to use in this context so maybe drawing this step by step with rounded corners could be a solution:

graph with random paths

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{positioning}

\begin{document}
    \tikzset
        {
        dot/.style={circle,draw,thick,fill=white,inner sep=2pt},
        rdm/.style={thick,dotted,rounded corners=5pt},
        }
    \begin{tikzpicture}[node distance=2cm]
        \draw[cyan] (-2,-2) grid (4,2);
        \node[dot,label=below left:$z_1$] (z1) {};
        \node[dot,above right = of z1,label=above right:$u$] (u) {};
        \node[dot,below right = of z1,label=below right:$v$] (v) {};
        \node[dot,above right = of v,label=below right:$z_2$] (z2) {};
        
        \draw[thick] (u) to[out=160,in=190,looseness=3] node[midway,left] {$e$} (v) ;
        
        \def\a{0.35}
        \draw[rdm] (z1) --++ (.5*\a,\a) --++ (\a,0) --++ (0,1.5*\a) node[left] {$P_1$} --++ (\a,0) --++ (0,\a) -- (u);
        \draw[rdm] (z1) --++ (0,-\a) --++ (\a,0) --++ (0,-1.5*\a) --++ (\a,0) --++ (0,-\a) -- (v);
        \draw[rdm] (v) --++ (\a,0.5*\a) --++ (\a,0) --++ (0,\a) --++ (\a,0) --++ (0,\a) --++ (\a,0) -- (z2);
        \draw[rdm] (u) --++ (.75*\a,0) --++ (0,-\a) --++ (1.75*\a,0) --++ (0,-\a) --++ (1.5*\a,0) node[right] {$P_2$} -- (z2);
        \path (u) -- (v) node[midway] {$f$};
    \end{tikzpicture}
\end{document}

This is obviously strongly customizable.