!!controle1=!shuffle $NN
!!controle2=!shuffle $NN

!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

!!on construit le diagramme de Voronoi mais on enlve les demi-droites
cnt_V=!linecnt $V
dessin=linewidth 1
!distribute  item -30,-30,30,30 into max1,max2,min1,min2
cnt_e=0
cnt_s=0
cnt_v=0
liste_vertex=
liste_vertex1=
liste_line=
liste_sommet=
liste_edge=
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
liste_vertex1=!append line  $A,$B to $liste_vertex1
!advance cnt_v
!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
!if $B<>-1 and $C<>-1  
!advance cnt_e
liste_edge=!append item $i to $liste_edge
droite=!item $[$A+1] of $liste_line
droite=!line $droite of $V
!distribute word  $droite into typ,a,b,c
vertex1=!item $[$B+1] of $liste_vertex
vertex1=!line $vertex1 of $V
!distribute word  $vertex1 into typ,v1,w1
vertex2=!item $[$C+1] of $liste_vertex
vertex2=!line $vertex2 of $V
!distribute word  $vertex2 into typ,v2,w2
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
!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
!endif
!next i
dessinnom=
!for i=1 to $cnt_v
u=!line $i of $liste_vertex1
abscisse$i=!item 1 of $u
ordonnee$i=!item 2 of $u
dessinnom=!append line text black,$(abscisse$i)+0.2 ,$(ordonnee$i)+0.2,medium,$(N$i)\
disk  $(abscisse$i) ,$(ordonnee$i),6,blue to $dessinnom 
!next i
border=1
min1=$[$min1-0.4*abs($min1)]
min2=$[$min2-0.4*abs($min2)]
  max1=$[$max1+0.2*abs($max1)]
 max2=$[$max2+0.2*abs($max2)]
 
!distribute item  $min1, $max1,$min2,$max2 into x_size1,x_size2,y_size1,y_size2
xx_size=$[$x_size2-($x_size1)]
yy_size=$[$y_size2-($y_size1)]
insdraw_size=400,400

!distribute item $insdraw_size into inssize1,inssize2
 
dessin_sommets=xrange  $x_size1,$x_size2\
yrange $y_size1,$y_size2\
$dessin\
$dessinnom

!! Matrice du graphe :
n=$cnt_v
M=!exec pari  print(matrix($n,$n))

!for i=1 to $cnt_e
edge= !item $i of $liste_edge
edge =!line $edge of $V
!distribute word $edge into e,l,a,b
M=!exec pari {M=Mat([$M]);\
M[$[$a+1],$[$b+1]]=1; M[$[$b+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

cnt_a=0
 !for i=1 to $n
        !for j=$i+1 to $n
    g=!exec pari  G=Mat([$G]); print(G[$i,$j])
    !if $g<>0
    !advance cnt_a
listea= !append line $i,$j to $listea
!endif
    !next j
    !next i
!! coefficients =1
!!cnt_a=!exec pari print(norml2(Mat([$G]))/2)
!if $gor=0
ccc=!exec pari Q=matrix(1,$n); print(Q)
!else
ccc=!exec pari Q=matrix(1,$cnt_a); print(Q)
!endif
