I am a beginner in TikZ. I want to draw a simple network with 2 nodes and a network like this:
My code is here:
\documentclass[border=1pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows, shapes, trees, calc}
\begin{document}
% Define styles
\tikzstyle{bnode}=[draw, fill=blue!20, text width=5em, text centered, minimum height=2.5em]
\begin{tikzpicture}
% draw two nodes
\node (node1) [bnode] at (0, 0) {Node 1};
\node (node2) [bnode] at (4, 0) {Node 2};
% draw network
% name this line to line1
\draw[line width=2pt] ($(node1.west |- node1.south)+(0, -.5)$) -- ($(node2.east |- node2.south)+(0, -.5)$);
% and draw a line between node1 and line1 like this:
% \draw[line width=2pt] (node1) -- (line1);
\draw[line width=2pt] (node1) -- (0, -.95);
\draw[line width=2pt] (node2) -- (4, -.95);
\end{tikzpicture}
\end{document}
I made the horizontal line drawn by the position of Node1 and Node2, but I don't know how to draw a relative vertical line. Can you help optimize the code?