Drawing function venn diagrams

tikz-pgf

I am having difficulty drawing the following pictures, so far I have only been able to draw the venn diagrams and not the elements inside them.

enter image description here

enter image description here

My code looks something like

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

\begin{document}
\begin{tikzpicture}
 
% Circle with label
\node[draw,
    circle,
    minimum size =2cm,
    label={135:$X$}] (circle1) at (-1,0){}; 

\fill (-1.5,0) circle[radius=0.1] node[above left]{a}; 

\node[draw,
    circle,
    minimum size =2cm,
    label={45:$Y$}] (circle2) at (3,0){};
 
\end{tikzpicture}
\end{document}

edit: I have used the comment below to add points but I don't know how to connect them

Best Answer

I do not like making the ellipse/circles nodes, so here is an alternative way where they are simply drawn:

\documentclass[tikz, border=1 cm]{standalone}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}
\draw[thick] (0,0) ellipse[x radius=2, y radius=3] +(-1.5,3) node{A};
\draw[thick] (7,0) ellipse[x radius=2, y radius=3] +(1.5,3) node{B};
\coordinate (a) at (0.5,2);
\coordinate (b) at (-1,1.5);
\coordinate (c) at (1,0);
\coordinate (p) at (6,1.5);
\fill (a) circle[radius=0.1] node[above left]{a};
\fill (b) circle[radius=0.1] node[below right]{b};
\fill (c) circle[radius=0.1] node[below left]{c};
\fill (p) circle[radius=0.1] node[below right]{p};
\draw[-Latex, shorten <=5pt, shorten >=5pt] (a) to[out=20, in=160] (p);
\draw[-Latex, shorten <=5pt, shorten >=5pt] (c) to[out=40, in=200] (p);
\end{tikzpicture}
\end{document}

Functional Venn diagram