# Broken line on Tikz Graph

Okay so my problem is this. I have this code (with the preamble containing a package of tikz, graphicx, and tikz library of positioning).

\documentclass[11pt]{article}
\usepackage{tikz, graphicx, geometry}
\geometry{margin=1in}
\usetikzlibrary{positioning}
\renewcommand{\baselinestretch}{1.4}

\begin{document}
\begin{figure}[h]\centering
\begin{tikzpicture}[round/.style={circle, draw=black!80, fill=black!10, very thick, minimum size=5mm}]
% Nodes
\node[round] (a) {a};
\node[round] (f) [right=of a] {f};
\node[round] (e) [below=of a] {e};
\node[round] (b) [below=of f] {b};
\node[round] (c) [right=of f] {c};
\node[round] (g) [below=of c] {g};
\node[round] (h) [right=of c] {h};
\node[round] (d) [right=of g] {d};
% Lines
\draw[very thick, =] (a.east) -- (f.west);
\draw[very thick, =] (f.east) -- (c.west);
\draw[very thick, =] (c.east) -- (h.west);
\draw[very thick, =] (a.south) -- (e.north);
\draw[very thick, =] (e.east) -- (b.west);
\draw[very thick, =] (b.east) -- (g.west);
\draw[very thick, =] (g.east) -- (d.west);
\draw[very thick, =] (f.south) -- (b.north);
\draw[very thick, =] (c.south) -- (g.north);
\draw[very thick, =] (h.south) -- (d.north);
\draw[very thick, =] (a.east) -- (f.west);
\draw[very thick, =] (a.east) -- (f.west);
\end{tikzpicture}
\end{figure}
\end{document}


Basically, I want to fix the crooked lines and make them straighter. I'd prefer a simple way to fix this, if there is any...

PS. Some of the code at the end was copy-pasted. Basically the lines were copy-pasted to speed up the task so ignore the last two lines. (I don't know if it helps to understand this if I remove them, but let me know.) EDIT: Sorry, I was referring to the lines

\draw[very thick, =] (a.east) -- (f.west);
\draw[very thick, =] (a.east) -- (f.west);


at the end here.. Apologies for the misconceptions. I'm not sure if I should completely include them.

PSS. Can't copy-paste full code. This is part of a school homework thing. But I think I got the main bits.

EDIT 2: Full graph should look sort of like this (this was my version taken from a textbook redrawn on paint but I want it to look more appealing).

Basically, the lines on paint are even worse. So I tried using tikz for the first time to add them.

• Welcome to TeX. SE. Please, complete your code document to LaTeX deocument which we can copy and compile on own computers. It sems that yor problem is that circles hasn't equal size. – Zarko Sep 27 '16 at 0:55
• Welcome! Please complete your code so that people can copy-paste-compile it. A minimal example should start \documentclass and end \end{document}. Also, please don't rely on acronyms which make it harder to understand your question - especially for non-native speakers of English, but also for non-native speakers of Acronyse, such as me. I figure Idk probably means I don't know. No idea about lmk. Could be lizards move koalas. However, I'm not sure that's on-topic here. Also, I have no idea what you mean about the last two lines of code. – cfr Sep 27 '16 at 0:56
• since the problem seems to be that the circles are not all the same size, because the contents are not all the same height + depth, it seems reasonable that if you could force the contents to the same size, the other problem would go away. into each circle add \vphantom{()} which will give them all the same vertical dimension. (actually, only one parenthesis is needed, but since most tex-directed editors like matching delimiters, specifying both will avoid unnecessary complaints there.) – barbara beeton Sep 27 '16 at 1:03
• @cfr Oh! I was referring to the repeated first line near the end. – Mad Maniac Sep 27 '16 at 1:08
• @barbarabeeton, I'm a little new to the tikz package so I'm not sure what you mean by adding \vphantom{()} to each circle. – Mad Maniac Sep 27 '16 at 1:10

Less concise than nice cfr answer ... instead graph use of the chain and define bigger minimum size of nodes.

\documentclass[tikz,
border=3mm
]{standalone}
\usetikzlibrary{chains}
\makeatletter
\tikzset{suppress join/.code={\def\tikz@after@path{}}}
\makeatother

\begin{document}
\begin{tikzpicture}[
start chain = A going right,
round/.style = {circle, draw=black!80, fill=black!10, very thick,
minimum size=7mm,
on chain, join=by {-, very thick}},
]
% Nodes
\begin{scope}[every node/.style = {round}]
\node (a) {a};
\node (f) {f};
\node (c) {c};
\node (h) {h};
\node (e) [suppress join,below=of a] {e};
\node (b) {b};
\node (g) {g};
\node (d) {d};
\end{scope}
% Lines
\draw[very thick]   (a) -- (e)
(a) to [bend left] (h)
(f) -- (b)
(c) -- (g)
(h) -- (d)
(e) to [bend right] (d);
\end{tikzpicture}
\end{document}


You could simply increase the minimum size. You could also set a uniform text height and text depth, while aligning the letters to the base line, like this. I didn't understand what you meant about removing bits of code, so I just made a simple example which does the same thing. The principle is the same with more verbose code: just set a standard height/depth for the text.

\documentclass[border=10pt,tikz]{standalone}
\usetikzlibrary{graphs}
\begin{document}
\begin{tikzpicture}
\graph [ nodes={circle, draw, fill=gray!30, anchor=mid, text height=1.5ex, text depth=.25ex} ]
{
a -- { f -- c -- h } , e -- b -- g -- d , a -- e , f -- b , c -- g , h -- d
};
\end{tikzpicture}
\end{document}


If you want the nodes the same size, add a standard text width and centre the contents.

\documentclass[border=10pt,tikz]{standalone}
\usetikzlibrary{graphs}
\begin{document}
\begin{tikzpicture}
\graph [ nodes={circle, draw, fill=gray!30, anchor=mid, text height=1.5ex, text depth=.25ex, text width=1.5ex, align=center} ]
{
a -- { f -- c -- h } , e -- b -- g -- d , a -- e , f -- b , c -- g , h -- d
};
\end{tikzpicture}
\end{document}


# EDIT

Note that the principle above is independent of how or what you draw between the nodes. It is just showing what adding text height=<>, text depth=<>, text width=<>, align=center does to the nodes' alignment.

However, you can add curves using the graph syntax I used above. For example,

\documentclass[border=10pt,tikz]{standalone}
\usetikzlibrary{graphs}
\begin{document}
\begin{tikzpicture}
\graph [ nodes={circle, draw, fill=gray!30, anchor=mid, text height=1.5ex, text depth=.25ex, text width=1.5ex, align=center} ]
{
a -- { f -- c -- h } , e -- b -- g -- d , a -- e , f -- b , c -- g , h -- d , a --[bend left] h , d --[bend left] e
};
\end{tikzpicture}
\end{document}


• I clarified in the edit what I meant there. To further clarify, I need to add curved edges from a to h and e to d. I'm quite new to tikz, so sorry for asking basic questions. I've only learned to interpret it based on sharelatex examples. And your code seems a bit different, so I'm not sure how to add those edges there. (I have a feeling that a--h and e--d will do straight lines but not sure.) – Mad Maniac Sep 27 '16 at 1:14
• But there are no curved lines in your MWE at all - only straight lines which you want to make straighter. Where did you ask about curves? But note that I'm just demonstrating the effect of adding text height=<>, text depth=<>, text width=<>, align=center to the nodes' style. It doesn't matter what you draw between the nodes. It is just demonstrating ways to align the nodes. If you use straight lines, they'll not be crooked. If you use curves, they'll be curved, obviously. – cfr Sep 27 '16 at 1:20
• @OsamaKawish Please see edit. – cfr Sep 27 '16 at 1:24