%%AMC:preprocess_command=/home/xxxxxxx/Projets-QCM/test-python/prePythonTex4AMC
%%AMC:jobspecific=1
%%AMC:latex_engine=pdflatex --shell-escape
%--------------------------

\documentclass[a4paper]{article}

\usepackage[utf8]{inputenc}    
\usepackage[T1]{fontenc}

\usepackage[francais,bloc,completemulti]{automultiplechoice}    
\usepackage{fancyhdr,amssymb,amsmath,graphicx}

% ---------- Utilisation de codes Python -----
\usepackage{pythontex}
%----------------------------------------------

\begin{pycode}
import networkx as nx
import numpy as np
from matplotlib import pyplot as plt

import random
random.seed(1235)
np.random.seed(1235)

G=nx.Graph()

G.add_node("A")
G.add_node("B")
G.add_node("C")
G.add_node("D")
G.add_node("E")

G.add_edge("A","C")
G.add_edge("B","C")
G.add_edge("B","D")
G.add_edge("C","D")
G.add_edge("D","E")

pos={ 
	"A":(np.random.randint(1,6),np.random.randint(1,6)),
	"B":(np.random.randint(1,6),np.random.randint(1,6)),
	"C":(np.random.randint(1,6),np.random.randint(1,6)),
	"D":(np.random.randint(1,6),np.random.randint(1,6)),
	"E":(np.random.randint(1,6),np.random.randint(1,6))
}

nx.draw(G,pos=pos,with_labels=True,node_color="red",node_size=3000,font_color="white",font_size=20, font_weight="bold",width=5,edge_color="black")

plt.savefig('graphique.png',bbox_inches='tight')

diametre=nx.diameter(G)
rayon=nx.radius(G)
centre=nx.center(G)
\end{pycode}

%--------
% DOCUMENT
%--------
\begin{document}

\exemplaire{5}{    

\IfFileExists{graphique.png}{\includegraphics[width=10cm]{graphique.png}}{}

\begin{questionmultx}{diametre}
	Quel est le diamètre du graphe ? 
	
	\pys{%
		\AMCnumericChoices{!{diametre}}{digits=1, decimals=0, sign=false, scoreexact=1, scorewrong=0, vspace=0em, hspace=2em, borderwidth=0pt, nozero}
	}
\end{questionmultx}


\begin{questionmultx}{rayon}
	Quel est le diamètre du graphe ? 
	
	\pys{%
		\AMCnumericChoices{!{rayon}}{digits=1, decimals=0, sign=false, scoreexact=1, scorewrong=0, vspace=0em, hspace=2em, borderwidth=0pt, nozero}
	}
\end{questionmultx}
}   

\end{document}
