I started learning TikZ today, and I got to the following image:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{graphs,positioning,arrows,shapes.misc,decorations.pathmorphing}
\tikzset{
>=stealth,
every picture/.style={thick},
graphs/every graph/.style={empty nodes},
}
\tikzstyle{vertex}=[
draw,
circle,
fill=black,
inner sep=1pt,
minimum width=5pt,
]
\begin{document}
\begin{tikzpicture}
\begin{scope}
\graph[ grow right = 2 ] {
u [vertex, label=$u$]
--[edge label=$e$]
v [vertex, label=$v$]
};
\end{scope}
\draw[->,thin] (3,0) -- (5,0) node [midway,above] {subdividing};
\begin{scope} [xshift=6cm]
\graph[ grow right = 1 ] {
u [vertex, label=$u$]
-- %[edge label=$e_{uv}$]
e [vertex, label=$v_e$]
-- %[edge label=$e_{vu}$]
v [vertex, label=$v$]
};
\end{scope}
\end{tikzpicture}
\end{document}
Is there a way to automatically vertically align the v_e
label with the u
and v
in the right graph?
Also, I like the graph
syntax, but I haven't found an easy way to have it making node labels next to the circle (like in the picture) instead of nodes with the name inside the circle without explicitly using the label
option.
Best Answer
I am not sure that
\smash
should be necessary here. It is not needed for theedge label
s ifanchor
is set tomid
. However, it does seem to be required for thenode
label
. But perhaps this is due to my unfamiliarity with thegraphs
library.You can use the
quotes
library to make it easier to labeledge
s, but I think you still needlabel
to labelnode
s.Note that it does not seem necessary to use
\smash
for the subscript in$e_{uv}$
.