how to draw bipartite graph with label?

by user2869180   Last Updated July 12, 2019 01:23 AM

I want to draw a bipartite graph like the following:

enter image description here

I tried the following code:


  every node/.style={draw,circle},
  every fit/.style={rounded corners,rectangle,draw,inner sep=-2pt,text width=2cm, dashed},
  ->,shorten >= 3pt,shorten <= 3pt

% the vertices of U
\begin{scope}[start chain=going below,node distance=7mm]
\foreach \i in {1,2}
  \node[fsnode,on chain] (f\i)  {$v_{\i}$};

% the vertices of V
\begin{scope}[xshift=4cm,yshift=0.6cm,start chain=going below,node distance=7mm]
\foreach \i in {6,7,8,9}
  \node[ssnode,on chain] (s\i)  {$v_{\i}$};

% the set U
\node [myblue,fit=(f1) (f2),label=above:$G^{P}$] {};
% the set V
\node [mygreen,fit=(s6) (s9),label=above:$G^{Q}$] {};

% the edges
\draw (f1) -- (s6);
\draw (f1) -- (s7);
\draw (f2) -- (s6);
\draw (f2) -- (s7);

It not give the same. In addition, how can I add a weight to this bipartite graph? The idea that I need also to add another graph on the right of the arrow. How can aggregate all?

Related Questions

Updated May 12, 2018 12:23 PM

Updated April 13, 2019 13:23 PM

Updated December 20, 2018 03:23 AM

Updated December 17, 2018 22:23 PM

Updated December 18, 2018 02:23 AM