How can I draw this figure centered within the following code
\documentclass{exam}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{amsthm}
\usepackage[colorinlistoftodos]{todonotes}
\usepackage[T1]{fontenc}
\usepackage{hyperref}
\usepackage[utf8]{inputenc}
\usepackage{txfonts}
\usepackage{url}\urlstyle{sf}
\usepackage[plain]{algorithm}
\usepackage {tikz}
\begin{document}
\begin{parts}
\part \begin{tikzpicture}
\node[rectangle,minimum width=2cm,minimum height=5cm] (m) {
\begin{minipage}{1.95cm}
\begin{tikzpicture}
\draw (0,5) node[minimum width=0.9cm, minimum height=0.9cm,draw] {$a$};
\draw (0,5) -> (1,5) node[minimum width=0.9cm, minimum height=0.9cm] {$a$};
\end{tikzpicture}
\end{minipage}
};
\draw[dashed] (m.south west) rectangle (m.north east);
\end{tikzpicture}
\end{parts}
\end{document}
and this is the image that a make



\documentclass{article}\usepackage{tikz}\begin{document}\begin{tikzpicture} ... \end{tikzpicture}\end{document}and read through the tutorials on the first pages of the TikZ manual. As you get stuck, post the code here and explain what you try to achieve. Keep the question as specific as possible. – Henri Menke Sep 10 '17 at 23:30partsenvironment do and what does\part, which is a sectioning command, have to do with the image? Do you want this to appear on a kind of part title page or something? If you're not familiar with\part, I'd suggest starting with an introduction to LaTeX before trying to learn TikZ. – cfr Sep 11 '17 at 00:13amsthm/ntheorem? Admittedly, thepartsthing is really unclear. – cfr Sep 11 '17 at 00:17