\documentclass{article}
\usepackage[a4paper,text={16cm,22.7cm},centering]{geometry}
\usepackage[pdflatex=true,recompilepics=auto]{gastex} 
\gasset{frame=true} % switch to false to remove frames
\parindent=0pt

\begin{document}

% \PDFcontainer

\begin{center} 
  \begin{gpicture}[name=loop]
    \node(A)(10,30){1}
    \gasset{loopangle=210}
    \drawloop[loopwidth=4](A){}
    \drawloop[loopwidth=6](A){}
    \drawloop[loopwidth=8](A){}
    \drawloop[loopwidth=10](A){}
    \drawloop[loopwidth=12](A){210}
    
    \gasset{loopangle=-30}
    \drawloop[loopheight=4](A){}
    \drawloop[loopheight=6](A){}
    \drawloop[loopheight=8](A){}
    \drawloop[loopheight=10](A){}
    \drawloop[loopheight=12](A){-30}
    
    \gasset{loopangle=90}
    \drawloop[loopdiam=4](A){}
    \drawloop[loopdiam=6](A){}
    \drawloop[loopdiam=8](A){}
    \drawloop[loopdiam=10](A){}
    \drawloop[loopdiam=12](A){90}

    \node(A)(40,30){}\node[Nw=5,Nh=5](B)(70,30){}\node(C)(110,30){}
    \drawqbedge(A,40,60,B){qbedge}
    \drawbpedge[ELpos=30,ELdist=0](A,45,20,B,225,20){bpedge}
    \drawbpedge[ELpos=50,ELside=l](A,210,25,B,-45,25){bpedge}
    \drawloop[loopdiam=10,loopangle=150,ELpos=70](A){larger}
  %   \drawloop[loopwidth=5,loopangle=180](A){smaller}
    \drawloop[loopwidth=5,loopangle=90](B){90}
    \drawedge(B,C){straight}
    \drawedge[curvedepth=8](B,C){positive curve depth}
    \drawedge[curvedepth=-8,ELside=r](B,C){negative curve depth}
  %   \drawbcedge(B,70,60,C,110,60){bcedge}
    \drawloop[loopangle=-30](C){-30}
    \drawloop[loopangle=60,loopCW=n,ELside=r](C){60}
  \end{gpicture}
\end{center}

%  The option "clip" does not work if we add it to the option list of gpicture. 
%  This is a problem with pst-pdf that I do not understand, hence I cannot fix. 
%  A solution is to use "ignore" in the option of gpicture and then define the 
%  viewport and clip as options of \gusepicture (see below).
\medskip
\hfil\gusepicture[viewport=0 5 88 90,clip]{loop}

% XML document

{\unitlength=.65mm
\begin{gpicture}[ignore=true,name=XMLdoc]
  \gasset{Nh=6,Nadjust=w,Nframe=n,linewidth=0.1,AHnb=0}
  
  \node[Nw=1,Nh=1](froot)(75,97){}
  \node(root)(10,90){\sf CarCatalogue}
  
  \node(a0)(-5,80){\sf CModel}
  \node(a1)(25,80){\sf CModel}
  
  \node(b0)(-17,70){\sf Part}
  \node(b1)(-5,70){\sf Part}
  \node(b2)(10,70){\ldots}
  
  \node(c0)(-17,60){\sf Description}
  \node(c1)(5,60){\ldots}
  
  \node(l)(5,52){$(a)$}
  
  \drawedge(root,a0){}
  \drawedge(root,a1){}  
  \drawedge(a0,b0){}
  \drawedge(a0,b1){}
  \drawedge(a0,b2){}
  \drawedge(b0,c0){}
  
  \drawedge(froot,root){}
  %%%%%%%%%%%%%%%%%%%%
  
  \node(root)(75,90){\sf PartCatalogue}
  \node(a0)(65,80){\sf PModel}
  \node(a1)(85,80){\sf PModel}
  
  \node(b0)(50,70){\sf Err}
  \node(b1)(65,70){\sf Err}
  \node(b2)(80,70){\ldots}
  
  \node(c0)(45,60){\sf Description}
  \node(c1)(65,60){\ldots}
  
  \drawedge(root,a0){}
  \drawedge(root,a1){}
  \drawedge(a0,b0){}
  \drawedge(a0,b1){}
  \drawedge(b0,c0){}
  
  \node(l)(70,52){$(b)$}
  
  \drawedge(froot,root){}    
  %%%%%%%%%%%%%%%%%%%% 
  
  \node(root)(140,90){\sf DealersDirectory}
  
  \node(a0)(130,80){\sf Dealer}
  \node(a1)(150,80){\sf Dealer}
  
  \node(b0)(120,70){\sf Sale}
  \node(b1)(140,70){\sf Sale}
  \node(b2)(155,70){\ldots}
  
  \node(c0)(110,60){\sf Car}
  \node(c1)(130,60){\sf Customer}
  
  \drawedge(root,a0){}
  \drawedge(root,a1){}
  
  \drawedge(a0,b0){}
  \drawedge(a0,b1){}
  \drawedge(b0,c0){}
  \drawedge(b0,c1){}
  
  \node(l)(135,52){$(c)$}
  \drawedge(froot,root){}
\end{gpicture}
}

\begin{figure}[t]
  \centering
  \gusepicture[viewport=0 4 346 82,scale=0.87]{XMLdoc}
  \label{fig:xmlcar}                                     
  \caption{Part of an XML document for the car database}
\end{figure}                                             

% The dfs tree
\begin{gpicture}[ignore=true,name=lessdfs](117,40)(-59,-40)
  \gasset{Nw=1.5,Nh=1.5,ExtNL=y,NLdist=1,AHnb=0}
  \node[NLangle=90](0)(0,0){0}
  
  \node[NLangle=135](1)(-50,-10){1}\drawedge(0,1){}
  \node[NLangle=0](2)(-50,-20){2}\drawedge(1,2){}
  \node[NLangle=180,Nfill=y](5)(-50,-30){5}\drawedge(2,5){}
  \node[NLangle=180](3)(-55,-40){3}\drawedge(5,3){}
  \node[NLangle=0](4)(-45,-40){4}\drawedge(5,4){}
  
  \node[NLangle=135](6)(-20,-10){6}\drawedge(0,6){}
  \node[NLangle=0](7)(-20,-20){7}\drawedge(6,7){}
  \node[NLangle=180](8)(-25,-30){8}\drawedge(7,8){}
  \node[NLangle=180,Nfill=y](10)(-15,-30){10}\drawedge(7,10){}
  \node[NLangle=0](9)(-15,-40){9}\drawedge(10,9){}

  \node[NLangle=45](11)(20,-10){11}\drawedge(0,11){}
  \node[NLangle=-90](14)(20,-20){14}\drawedge(11,14){}
  \node[NLangle=180](12)(10,-20){12}\drawedge(11,12){}
  \node[NLangle=180](13)(10,-30){13}\drawedge(12,13){}
  \node[NLangle=0](15)(30,-20){15}\drawedge(11,15){}
  \node[NLangle=180](16)(25,-30){16}\drawedge(15,16){}
  \node[NLangle=180](17)(25,-40){17}\drawedge(16,17){}
  \node[NLangle=0,Nfill=y](19)(35,-30){19}\drawedge(15,19){}
  \node[NLangle=0](18)(35,-40){18}\drawedge(19,18){}

  \node[NLangle=0,Nfill=y](23)(50,-10){23}\drawedge(0,23){}
  \node[NLangle=0](20)(50,-20){20}\drawedge(23,20){}
  \node[NLangle=0,Nfill=y](22)(50,-30){22}\drawedge(20,22){}
  \node[NLangle=0](21)(50,-40){21}\drawedge(22,21){}

  \gasset{AHnb=1,ELdist=0.5,dash={1.2}0,linecolor=red}
  \drawedge[ELside=r,curvedepth=-4](0,1){\textcolor{red}{1}}
  \drawedge[ELside=r,curvedepth=-2](1,2){\textcolor{red}{1}}
  \drawedge[ELside=r,curvedepth=-4](2,3){\textcolor{red}{2}}
  \drawedge[ELside=r,curvedepth=-2](3,4){\textcolor{red}{3}}
  \drawedge[ELside=r,curvedepth=-2](4,5){\textcolor{red}{5}}
  \drawedge[ELside=l,curvedepth=4](5,6){\textcolor{red}{9}}
  
  \drawedge[ELside=r,curvedepth=-2](6,7){\textcolor{red}{1}}
  \drawedge[ELside=r,curvedepth=-2](7,8){\textcolor{red}{1}}
  \drawedge[ELside=r,curvedepth=-2](8,9){\textcolor{red}{4}}
  \drawedge[ELside=r,curvedepth=-2](9,10){\textcolor{red}{5}}
  \drawedge[ELside=l,curvedepth=9](10,11){\textcolor{red}{9}}

  \drawedge[ELside=r,curvedepth=-2](11,12){\textcolor{red}{1}}
  \drawedge[ELside=r,curvedepth=-2](12,13){\textcolor{red}{1}}
  \drawedge[ELside=l,curvedepth=1](13,14){\textcolor{red}{6}}
  \drawedge[ELside=l,curvedepth=0](14,15){\textcolor{red}{3}}
  \drawedge[ELside=r,curvedepth=-2](15,16){\textcolor{red}{1}}
  \drawedge[ELside=r,curvedepth=-2](16,17){\textcolor{red}{1}}
  \drawedge[ELside=l,curvedepth=6](17,18){\textcolor{red}{7}}
  \drawedge[ELside=r,curvedepth=-2](18,19){\textcolor{red}{5}}
  \drawedge[ELside=l,curvedepth=2](19,20){\textcolor{red}{10}}

  \drawedge[ELside=r,curvedepth=-4](20,21){\textcolor{red}{2}}
  \drawedge[ELside=r,curvedepth=-2](21,22){\textcolor{red}{5}}
  \drawedge[ELside=r,curvedepth=-6](22,23){\textcolor{red}{8}}
\end{gpicture}

\vspace{10mm}\hfil
\gusepicture[viewport=0 5 332 127,scale=0.85]{lessdfs}

\end{document}

