I'm trying to draw a graph in tikz.

\usepackage{tikz, subfigure}
\usepackage[papersize={100mm, 100mm}, text={100mm, 100mm}]{geometry}
\tikzstyle{every node}=[draw,shape=circle]


\begin {figure}[1]

  \subfigure[picture 1]{
\tikzstyle{every node}=[draw,shape=circle]

\draw[xshift=-1cm] (0,0) coordinate[label=above:$a$](a) -- (1,0) coordinate [label=below:$u_1$](b);
\draw[xshift=-1cm] (2,0) coordinate[label=below:$v_1$](c) -- (3,0) coordinate [label=below:$u_2$](d);
\draw[xshift=-1cm] (4,0) coordinate[label=below:$v_2$](e) -- (5,0) coordinate [label=above:x](f);
\draw[xshift=-1cm] (5,0) coordinate[label=above:x] -- (6,0) coordinate [label=above:b](B);

\draw (b) to[out=110,in=70] ++(2,0);
\draw (c) to[out=110,in=70] ++(2,0);


But can't find how to draw dots on a, v1, v2 etc. Can you help me?


You can use nodes instead of coordinates like

node[circle,fill,inner sep=1pt,label=above:$a$](a){}


\tikzset{every node/.style={draw,shape=circle}}


\tikzstyle{every node}=[draw,shape=circle]

\draw[xshift=-1cm] (0,0) node[circle,fill,inner sep=1pt,label=above:$a$](a){} -- (1,0) 
node[circle,fill,inner sep=1pt,label=below:$u_1$](b){};
\draw[xshift=-1cm] (2,0) node[circle,fill,inner sep=1pt,label=below:$v_1$](c) {} -- (3,0) 
node[circle,fill,inner sep=1pt,label=below:$u_2$](d){};
\draw[xshift=-1cm] (4,0) node[circle,fill,inner sep=1pt,label=below:$v_2$](e){} -- (5,0) 
node[circle,fill,inner sep=1pt,label=above:x](f){};
\draw[xshift=-1cm] (5,0) node[circle,fill,inner sep=1pt] {} -- (6,0) node[circle,fill,inner sep=1pt,label=above:b](B){};

\draw (b) to[out=110,in=70] ++(2,0);
\draw (c) to[out=110,in=70] ++(2,0);


enter image description here

Another option is to draw the circle separately like

\fill (a) circle[radius=1pt];

Do the same for other points also.

You have to correct these in your code though:

  1. Don't use \tikzstyle. It is deprecated. Use tikzset instead.
  2. Don't use subfigure (deprecated). Use subcaption (which gives subfigure environment) or subfig (which gives subfloat)
  3. in the optional argument of figure environment, You have used [1] which is wrong. It has to be [htbp].
  • Is it possible to draw similar graphics using the graph syntax? I can't (easily) get the node names to be displayed as labels instead of inside the nodes. – Ragnar Oct 9 '15 at 19:45
  • @Ragnar Please open a mew thread with your code with nodes. Also you may ask another new question for graphs syntax. – user11232 Oct 9 '15 at 23:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.