In the following example, I want the line segments to be connected at each vertex. For example, I want E1 and E2 to have a common end point and label V2 should be used to label that end point. How should I modify the code? Thanks.
\documentclass[]{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node at (0,0) (nodeA) {$V_1$};
\node at (2,2) (nodeB) {$V_2$};
\node at (3,0) (nodeC) {$V_3$};
\node at (5,1) (nodeD) {$V_4$};
\draw (nodeA) -- (nodeB) -- (nodeC) -- (nodeD);
\draw (nodeA) -- (nodeB) node [midway, above, sloped] (EdgeAB) {$E_1$};
\draw (nodeB) -- (nodeC) node [midway, above, sloped] (EdgeBC) {$E_2$};
\draw (nodeC) -- (nodeD) node [midway, above, sloped] (EdgeCD) {$E_3$};
\end{tikzpicture}
\end{document}
(nodeB)
by(nodeB.south)
and(nodeC)
by(nodeC.north)
.