You can use Math
option. But this can't be mixed with other vertices which are not having math content. Hence we have to split the entire line and use x
and y
values to position them properly:
\Vertices{line}{0,1}
\Vertex[Math,L=\ldots,x=4,y=0] {dots}
\Vertices[x=6,y=0]{line}{i,i+1}
\Vertex[Math,L=\ldots,x=10,y=0] {dots2}
Full code:
\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath, amssymb, amsthm}
\usepackage{tkz-graph}
\tikzset{EdgeStyle/.append style = {->}}
\tikzset{LabelStyle/.style= {draw,
fill = white,
text = black}}
\begin{document}
\begin{tikzpicture}
\SetGraphUnit{2}
\Vertices{line}{0,1}
\Vertex[Math,L=\ldots,x=4,y=0] {dots}
\Vertices[x=6,y=0]{line}{i,i+1}
\Vertex[Math,L=\ldots,x=10,y=0] {dots2}
\Edge[label=q](1)(0)
\tikzset{EdgeStyle/.append style = {bend left}}
\Edge[label=p](1)(dots)
\Edge[label=q](dots)(1)
\Edge[label=p](dots)(i)
\Edge[label=q](i)(dots)
\Edge[label=p](i)(i+1)
\Edge[label=q](i+1)(i)
\Edge[label=p](i+1)(dots2)
\Edge[label=q](dots2)(i+1)
\end{tikzpicture}
\end{document}
![enter image description here](https://i.stack.imgur.com/XktTN.png)
Instead of explicitly defining a new counter \j
you can use evaluate
. Of course, this isn't much of a saving as you still need to define \j
inside the evaluate
statment, but it does save a loop:
![enter image description here](https://i.stack.imgur.com/JSy8e.jpg)
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{graphs}
\usetikzlibrary{graphs.standard}
\begin{document}
\begin{tikzpicture}[every node/.style={draw,circle,very thick}]
\graph[clockwise, radius=2cm] {subgraph C_n [n=5,name=A] };
\graph[clockwise, radius=1cm] {subgraph I_n [n=5,name=B] };
\foreach \i [evaluate={\j=int(mod(\i+2+4,5)+1)}]% using Paul Gaborit's optimisation
in {1,2,3,4,5}{
\draw (A \i) -- (B \i);
\draw (B \j) -- (B \i);
}
\end{tikzpicture}
\end{document}
Note that you need to take int(...)
of the mod
statement because otherwise you are asking to draw edges like (B 1.0) -- (B 3.0)
, which is not what you want.
Best Answer
Here is one attempt using tikz:
The code: