I want to extend the implementations of the examples here to represent graphs with vertices simply represented as text as shown in the figure below.

I wasn't able to find similar templates/examples in the tikz manual. Could someone point me to a MWE?


You can modify Gonzalo's code (from the accepted answer to the question you refer to) to only have text, for example



% the vertices of U
\begin{scope}[start chain=going below,node distance=7mm]
\foreach [count=\i] \txt/\xcoord/\ycoord in {ABC/6/8,CDE/5/1,FGH/-4/7,IJK/6/9,LMN/0/-3}
  \node[on chain] (f\i) {\txt};

% the vertices of V
\begin{scope}[xshift=4cm,yshift=-0.5cm,start chain=going below,node distance=7mm]
\foreach [count=\i from 6] \txt/\xcoord/\ycoord in {OPQ/0/3,RST/1/4,UVW/-2/1,XYZ/5/9}
  \node[on chain] (s\i) {\txt};

% the edges
\draw (f1) --node{1} (s6);
\draw (s6) --node[swap]{2} (f2);
\draw (f2) --node{3} (s7);
\draw (s7) --node{4} (f3);
\draw (s8) --node{5} (f3);
\draw (f3) --node[swap]{6} (s9);
\draw (s9) --node{7} (f5);
\draw (f5) --node{8} (s6);


enter image description here

  • Could you point to Gonzalo's code? – envy_intelligence Apr 3 '16 at 10:14
  • 1
    @envy_intelligence You did that ... It's the accepted answer to the question you referred to. – Torbjørn T. Apr 3 '16 at 10:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.