The following code produces two graphs and I wanted arrows everywhere, but only some edges are arrows, the other are normal edges.

I don't understand how it is even possible. The arrow edges in the end are p1->p2, q2->q3 and q2'->q4

\node at (-1,-.5) {$H:$};
\node[vertex] (p1) at (0,0) {};
\node[vertex] (p2) at (0,-1) {};
\node[vertex] (p3) at (-1,-2) {};
\node[vertex] (p4) at (1,-2) {};
\draw[->] (p1) -- (p2);;
\draw[->] (p2) -- (p3);
\draw[->] (p2) -- (p4);
\node at (3.5,-.5) {$G:$};
\node[vertex] (q1) at (5,0) {};
\node[vertex] (q2) at (4,-1) {};
\node[vertex] (q2') at (6,-1) {};
\node[vertex] (q3) at (4,-2) {};
\node[vertex] (q4) at (6,-2) {};
\draw[->] (q1) -- (q2);
\draw[->] (q1) -- (q2');
\draw[->] (q2) -- (q3);
\draw[->] (q2') -- (q4);
  • Welcome! Thanks for providing code. If you could complete it to make it compilable, that would be great. – cfr Feb 15 '16 at 23:42
  • Your code produces 2 graphs here: the 1st contains 3 arrows; the 2nd contains 4. – Sigur Feb 15 '16 at 23:42
  • 2
    I get arrows everywhere, too, when I just add minimal code needed to compile. [Though this is a very inefficient way to draw trees.] – cfr Feb 15 '16 at 23:43
  • Maybe it is a zoom problem. – Sigur Feb 15 '16 at 23:45
  • Welcome to LaTeX! Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers. – JP-Ellis Feb 20 '16 at 0:20

TikZ has a graph drawing library which will make the drawing of these graphs significantly easier.

In the following example, the baseline key sets the vertical alignment of the graphs with the H and G. With each node, the part before the slash / identifies the node uniquely so that it can be used again in the layout specification. For example, you cold add another edge connecting nodes 3 and 4 in H by adding 3 -- 4, in the graph specification.

The part in the quotes determines the label (or text) in the node.



\tikz [baseline=(2), >=stealth] \graph [tree layout, nodes={draw,circle}] {
  1/"" -> 2/"" -> {3/"", 4/""},
\tikz [baseline=(2), >=stealth] \graph [tree layout, nodes={draw,circle}] {
  1/"" -> {2/"" -> 3/"", 4/"" -> 5/""}, 


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.