!!controle1=!shuffle  $NN
!!controle2=!shuffle $NN
!!controle= !translate internal ; to $\
$ in $controle
!!controle1=!line 1 of $controle
!!controle2=!line 2 of $controle
!!point1=!exec pari print(mattranspose([$controle1;$controle2]))

!read voronoi_data
controle= !randline $data

point1=!exec pari print(mattranspose([$controle]))
point =!items2words $point1
point =!translate internal ; to $\
$ in $point
point1 =!translate internal ; to $\
$ in $point1
V=!exec voronoi $point
T=!exec voronoi -t $point

cnt_V=!linecnt $V
cnt_T=!linecnt $T
dessin=linewidth 1
!distribute  item -3000,-3000,3000,3000 into max1,max2,min1,min2
!distribute item 0,0, into cnt_e,cnt_s,liste_vertex,liste_line,liste_sommet,sommet
!for i=1 to $cnt_V
	data=!line $i of $V
	!distribute word  $data into type,A,B,C
	!if $type=v
		liste_vertex=!append item $i to $liste_vertex
	!endif
	!if $type=s
		!advance cnt_s
		liste_sommet=!append item $i to $liste_sommet
	!endif
	!if $type=l
		liste_line=!append item $i to $liste_line
	!endif
	!if $type=e
		!advance cnt_e
		droite=!item $[$A+1] of $liste_line
		droite=!line $droite of $V
		!distribute word  $droite into typ,a,b,c
		!if $B<>-1
			vertex1=!item $[$B+1] of $liste_vertex
			vertex1=!line $vertex1 of $V
			!distribute word  $vertex1 into typ,v1,w1
		!endif
		!if $C<>-1
			vertex2=!item $[$C+1] of $liste_vertex
			vertex2=!line $vertex2 of $V
			!distribute word  $vertex2 into typ,v2,w2
		!endif
		!if $C<>-1 and $B<>-1
			max=!sort  numeric item $v1,$v2, $max1
			min=!sort  numeric item $v1,$v2, $min1
			max1= !item -1  of $max
			min1= !item 1 of $min
			max=!sort  numeric item $w1,$w2, $max2
			min=!sort  numeric item $w1,$w2, $min2
			max2= !item -1  of $max
			min2= !item 1 of $min
			color=blue
		!endif
		!if $B=-1
			!distribute item -100,-100  into v1,w1
		!endif
		!if $C=-1
			!distribute item 100,100  into v2,w2
		!endif
		!if $b<>0
			dessin=!append line trange  $v1,$v2 to $dessin
			dessin=!append line plot $color,t, (-($a)*t+($c))/$b to $dessin
		!else
			dessin=!append line trange  $w1,$w2 to $dessin
			dessin=!append line plot $color, (-($b)*t+($c))/($a),t to $dessin
		!endif
	!endif
!next i
cnt_point=!linecnt $point1
n=$cnt_s
!if $inv=1
	listemixte=!item 1 to $n of a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,z
	listemixte=!shuffle  $listemixte
	listepos= $wims_shuffle_order
	!distribute item $listemixte into M1,M2,M3,M4,M5,M6,M7,M8,M9,M10,M11,M12,M13,M14,M15,M16,M17,M18,M19,M20,M21,M22,M23,M24,M25,M26
!else
	!for i=1 to $n
		M$i=$(N$i)
	!next i
!endif	

dessinnom=
!for i=1 to $n
	u=!line $i of $point1
	dessinnom=!append line text black,$u ,medium,$(M$i) to $dessinnom
	!distribute item $u into u1, u2
	min1=$[min($min1,$u1)]
	min2=$[min($min2,$u2)]
	max1=$[max($max1,$u1)]
	max2=$[max($max2,$u2)]
!next i

 min1=$[$min1-0.5*abs($max1)]
  min2=$[$min2-0.5*abs($max2)]
  max1=$[$max1+0.5*abs($max1)]
 max2=$[$max2+0.5*abs($max2)]
 
dessin=!append line $dessin to  xrange  $min1, $max1\
yrange $min2,$max2
dessin=$dessin\
$dessinnom
!! Matrice du graphe : 
M=!exec pari  print(matrix($cnt_s,$cnt_s))
!for i=1 to $cnt_T
	triangle= !line $i of $T
	!distribute word $triangle into a,b,c
	M=!exec pari {M=Mat([$M]);\
M[$[$a+1],$[$b+1]]=1; M[$[$b+1],$[$a+1]]=1;\
M[$[$c+1],$[$b+1]]=1;M[$[$b+1],$[$c+1]]=1;\
M[$[$a+1],$[$c+1]]=1;M[$[$c+1],$[$a+1]]=1;\
print(M)}
!next i

G=!trim $M
GM=!translate internal ; to $\
$ in $G
etp=0
GC=!exec pari M=matrix($n,$n,i,j,0);print(M)
D=$G
GCM=!translate internal ; to $\
$ in $GC
	DM=!translate internal ; to $\
$ in $D

!if $inv=1
	listepos= !item 1 to $n of $listepos
	listemixte= !item 1 to $n of $listemixte
!endif	
