function CheckScheme(A)
  n:= Ncols(A);

  // Die Gammas ausrechnen
  G:= [ {<i,i> : i in [1..n]}, {<i,j> : i,j in [1..n] | A[i,j] ne 0} ];
  touched:= n + #G[2];
  while touched ne n^2 do
    B:= A^#G;
    X:= {<i,j> : i,j in [1..n] | B[i,j] ne 0} diff (&join G);
    Append(~G, X);
    touched +:= #X;
  end while;

  // Jetzt die Schnittmatrizen
  A:= [ Matrix(SparseMatrix(n, n, [ <x[1], x[2], 1> : x in g ])) : g in G ];

  // Wir koennen nun die Strukturkonstanten p_{i,j}^k mit linearer Algebra bestimmen:
  ProdMatrix := Matrix([ Eltseq(a*b) : a,b in A ]);
  BasisMatrix:= Matrix([ Eltseq(a)   : a   in A ]);
  ok, P:= IsConsistent(ProdMatrix, BasisMatrix);

  // oder direkt die Definition nachrechnen
  ok2:= forall{<i,j,k> : i,j,k in [1..#G] |
     #{ #{ z: z in [1..n] | <x[1],z> in G[i] and <z,x[2]> in G[j] } : x in G[k] } eq 1 };

  assert(ok eq ok2);
  return ok, A;
end function;

// Die Adjazenzmatrix W eines W"urfels:
W:= Matrix(8, [
0,1,0,1,1,0,0,0,
1,0,1,0,0,1,0,0,
0,1,0,1,0,0,1,0,
1,0,1,0,0,0,0,1,
1,0,0,0,0,1,0,1,
0,1,0,0,1,0,1,0,
0,0,1,0,0,1,0,1,
0,0,0,1,1,0,1,0 ]);



// Die Adjazenzmatrix I eines Ikosaeders (vgl. Blatt 2)
G:= CosetImage(Alt(5), sub< Alt(5) | (1,2,3) >);
Pot5:= GSet( G, Subsets({1..20}, 5));
Flaechen:= [ x: x in Orbits(G, Pot5) | #x eq 12 ][1];
Pot2:= GSet( G, Subsets({1..20}, 2));
Kanten:= [ o: o in Orbits(G, Pot2) | #o eq 30 and exists{a: a in o | a subset Flaechen[1]} ][1];

I:= MatrixRing(Integers(), 20) ! 0;
for Kante in Kanten do
  i,j:= Explode(Setseq(Kante));
  I[i,j]:= 1; I[j,i]:= 1;
end for;


// Jetzt unsere Testfunktion aufrufen...
ok, AW:= CheckScheme(W); 
ok; AW[2..#AW];

ok, AI:= CheckScheme(I);
ok; AI[2..#AI];
