\documentclass[12pt,twoside]{book}
\usepackage{tikz}
\usepackage[all]{xy}
\usetikzlibrary{shapes,arrows,positioning}
\usepackage{xepersian}

\begin{document} 
\begin{tikzpicture}[nd/.style={circle,inner sep =2pt, outer sep=3pt,draw,thick},scale=1,->=latex,thick]

\node[nd,fill=red!10,label={$a$}] (a) at (0,0) {$A$};
\node[nd,label={$b$}] (b) at (2,0) {$B$};
\node[nd,label={below:$c$}] (c) at (2,-2) {$C$};
\node[nd,,fill=blue!10,label={below:$d$}] (d) at (4,-2) {$D$};

\draw (a) -- (b) node[midway,sloped,above] {$f$};
\draw (b) -- (c) node[midway,right] {$g$};
\draw (a) -- (c) node[midway,sloped,below] {$f;g$};
\draw (c) -- (d) node[midway,sloped,below] {$h$};
\draw (b) -- (d) node[midway,sloped,above] {$f;g$};
\end{tikzpicture}

\entrymodifiers={=<1.3pc>[o][F-]}
\xymatrix{
A \ar[dr]_{f;g} \ar[r]^{f} & B \ar[d]^{g} \ar[dr]^{g;h}  \\ 
*[][]{}&C \ar[r]_{h}& D
}
\end{document}

