\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{tikz}
\tikzstyle{vertex}=[auto=left,circle,fill=black!25,minimum size=20pt,inner sep=0pt]
\begin{document}
\begin{tikzpicture}
\node[vertex] (n1) at (1,4) {s};
\node[vertex] (n2) at (3,2) {};
\node[vertex] (n3) at (3,3) {};
\node[vertex] (n4) at (3,4) {};
\node[vertex] (n5) at (3,6) {};
\node[vertex] (n6) at (9,4) {t};
\node[vertex] (n7) at (7,6) {};
\node[vertex] (n8) at (7,4) {};
\node[vertex] (n9) at (7,3) {};
\node[vertex] (n10) at (7,2) {};
\foreach \from/\to in {n1/n2,n1/n3,n1/n4,n1/n5,
n6/n7,n6/n8,n6/n9,n6/n10}
\draw[densely dotted] (\from) -- (\to);
\foreach \from/\to in {n2/n10,n3/n9,n4/n8,n5/n7}
\draw(\from) -- (\to);
\end{tikzpicture}
\end{document}
I am trying to get vertical dots between nodes (n4,n5)
and (n6,n7)
. I have tried many ways but nonetheless.
Also I am trying t add edge weights to the graph. I keep finding links to those written in the form of a matrix.
I need to add text representing the left and right nodes on the tree. How do we add text at desired place in the tree?
Best Answer
To place any character, such as
\dots
, you can use a\path
and place the required character via anode
and use thesloped
option so that the character is rotated along the path:If you are not satisfied with these, you could add small filled circles.
The nodes at the start and end can be added and positions via a
left
/right
option so the text is placed to the left/right of the specfic point of the node:To add text above each edge you can add another option to the
\foreach
loop and place the text via a node:Code: