# How to draw the graph below using TikZ in LaTeX?

Please help me drawing this in LaTex. Even just a few nodes, I will try to finish it. I just don't know what syntax to use. Thank you.

This is what I've got, however, the output for the values of the edges are not very clear. How do I avoid this?

    [third corner of triangle={A=A,B=B,a=2.1,b=2.4}]
coordinate[bullet={below left:$I$}] (I)
[third corner of triangle={A=I,B=B,a=2.6,b=3.6}]
coordinate[bullet={above:$C$}] (C)
[third corner of triangle={A=I,B=C,a=3.3,b=2.8}]
coordinate[bullet={above leftf:$J$}] (J)
[third corner of triangle={A=A,B=I,a=1.8,b=3.4}]
coordinate[bullet={below :$H$}] (H)
[third corner of triangle={A=H,B=J,a=3.2,b=1.7}]
coordinate[bullet={below:$G$}] (G)
[third corner of triangle={A=G,B=C,a=2.9,b=5.3}]
coordinate[bullet={above:$D$}] (D)
[third corner of triangle={A=D,B=C,a=4.2,b=2.2}]
coordinate[bullet={right:$E$}] (E)
[third corner of triangle={A=J,B=E,a=4.4,b=2.5}]
coordinate[bullet={below:$F$}] (F)

(B) edge["2.6"] (C)
(A) edge["3.4"] (H)
edge["2.4"] (I)
(I) edge["1.8"] (H)
edge["2.1"] (B)
edge["2.8"] (J)
(C) edge["3.3"] (J)
edge["3.6"] (I)
(D) edge["2.9"] (C)
edge["5.3"] (G)
(E) edge["4.2"] (C)
edge["2.2"] (D)
edge["4.4"] (F)
(F) edge["2.1"] (D)
edge["2.5"] (J)
(G) edge["1.7"] (H)
edge["3.2"] (J)
edge["5.3"] (D);


Welcome! A triangle is completely fixed by two corners and the lengths of the other sides. One can define a style for that. The style can be used as

[third corner of triangle={A=<name of first corner>,
B=<name of second corner>,
a=<length of side opposite to first corner>,
b=<length of side opposite to second corner>}]


This allows you to draw your diagram. Here is a start.

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{calc,quotes}
\begin{document}
\begin{tikzpicture}[bullet/.style={circle,draw,fill,inner sep=1.5pt,label=#1},
auto,shortcut/.code={\def\pv##1{\pgfkeysvalueof{/tikz/#1/##1}}},
third corner of triangle/.style={shortcut=triangle pars,
triangle pars/.cd,#1,
/tikz/insert path={
let \p1=($(\pv{A})-(\pv{B})$),\n1={sqrt(pow(\x1/1cm,2)+pow(\y1/1cm,2))},
\n2={atan2(\y1,\x1)} in
(intersection cs:first line={(\pv{A})--($(\pv{A})+({\n2-cosinelaw(\n1,\pv{b},\pv{a})}:1)$)},
second line={(\pv{B})--($(\pv{B})+({\n2+cosinelaw(\n1,\pv{a},\pv{b})}:1)$)})
}},
declare function={cosinelaw(\a,\b,\c)=acos((\a*\a+\b*\b-\c*\c)/(2*\a*\b));},
triangle pars/.cd,
A/.initial=A,B/.initial=B,a/.initial=2,b/.initial=2]
\draw (0,0) coordinate[bullet={left:$A$}] (A)
to["2.7"] ++ (50:2.7) coordinate[bullet={above:$B$}] (B)
[third corner of triangle={A=A,B=B,a=2.1,b=2.4}]
coordinate[bullet={below:$I$}] (I)
[third corner of triangle={A=I,B=B,a=2.6,b=3.6}]
coordinate[bullet={above:$C$}] (C)
[third corner of triangle={A=I,B=C,a=3.3,b=2.8}]
coordinate[bullet={above:$J$}] (J)
[third corner of triangle={A=A,B=I,a=1.8,b=3.4}]
coordinate[bullet={left:$H$}] (H)
(B) edge["2.6"] (C)
(A) edge["3.4"] (H)
edge["2.4"] (I)
(I) edge["1.8"] (H)
edge["2.1"] (B)
edge["2.8"] (J)
(C) edge["3.3"] (J)
edge["3.6"] (I);
\end{tikzpicture}

\end{document}


• Thank you so much for your help. I have finished the graph but the values of the edges coincide. Is there a way to fix this? Please see my edits. – Miriam Jan 15 at 2:20
• Is it also possible to change the color of the edges and the nodes? – Miriam Jan 15 at 2:23
• @Miriam The values are indicated in the quotes. So if you change (C) edge["3.3"] (J) to (C) edge["4.7"] (J), 3.3 will change to 4.7 (but in the example the positions of the vertices were computed for the distances indicated there). If you change it to (C) edge["3.3",blue] (J), the edge will turn blue. – Schrödinger's cat Jan 15 at 2:33
• Why not graphdrawing? – Henri Menke Jan 15 at 3:34
• @HenriMenke Please feel free to add a graph drawing answer. I have burnt my claws with those, whenever I used it someone else would add an answer that does things by hand. In any case, you will probably need somewhere some method that determines the locations of these points. – Schrödinger's cat Jan 15 at 3:59