color=brown
M1=!exec pari print(matrix($NN,$N,i,j,random(2)))
M=!translate internal ; to $\
$ in $M1
m=$[$N+1]
mm=$[$NN+1]

!! n est le nombre de sommets
n=0
dessin=xrange -1,$[$m+1]\
yrange -1,$[$mm+1]\
linewidth 4\
line 0,1,0,$mm,$color\
line $m,1,$m,$mm,$color

!for j=1 to $mm
	!advance n
	graphe=!append item ; $j,1 to $graphe
	dessin=$dessin\
	line 0,$j,$m,$j,$color
	s=!line $j of $M
	!for i=1 to $N
		u=!item $i of $s
		!if $u=1
		dessin=$dessin\
line $i,$j,$i,$[$j+1],$color
		!advance n
		graphe=$graphe ;$j
	!endif
	graphe=!append item $[$i+1] to $graphe
	!next i
!next j

graphe=!nospace $graphe
graphe =!replace internal ,; by ; in $graphe
graphe =!replace internal ;, by ; in $graphe
graphe=!translate internal ; to $\
$ in $graphe

graphe=!line from 1 to -2 of $graphe
graphe=!nonempty lines $graphe
cnt=!replace internal ; by + in $M1
cnt=!replace internal , by + in $cnt

cnt=$[$cnt+$NN]
n=!linecnt $graphe

!!calcul de la matrice du graphe et lettres dans le dessin
G=!exec pari M=matrix($n,$n); print(M)
!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	
!for i=1 to $n
	L=!line $i of $graphe
	L1=!item 1 of $L
	l=!item 2 of $L
	ll=!item -1 of $L
	dessin = $dessin\
text $color, $[($l+$ll-1)/2],$[$L1+1/2],medium,$(M$i)
	!for j=$[$i+1] to $n
		LL=!line $j of $graphe
		LL1=!item 1 of $LL
		!if $LL1=$L1 and $[$i+1]=$j
			G=!exec pari M=Mat([$G]); M[$i,$j]=1; print(M)
		!endif
		!if $LL1=$[$L1+1] 
			S=!item 2 to -1 of $L
			SS=!item 2 to -1 of $LL
			U=!listintersect $S and $SS
			!if $U<>$empty
				G=!exec pari M=Mat([$G]); M[$i,$j]=1; print(M)
			!endif
		!endif
	!next j
!next i

G=!exec pari M=Mat([$G]); print(M+M~)

G=!trim $G
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


