RelationMatrixSortedByClosedSubset

RelationMatrixSortedByClosedSubset(R, L) returns a relation matrix sorted by a partition determined by a closed subset L. For example,

gap> Display(R);
[ [  0,  1,  2,  2,  2,  2,  2,  3,  3,  3,  3,  3 ],
  [  1,  0,  3,  3,  3,  3,  3,  2,  2,  2,  2,  2 ],
  [  2,  3,  0,  2,  2,  3,  3,  1,  2,  2,  3,  3 ],
  [  2,  3,  2,  0,  3,  2,  3,  3,  2,  3,  1,  2 ],
  [  2,  3,  2,  3,  0,  3,  2,  3,  3,  2,  2,  1 ],
  [  2,  3,  3,  2,  3,  0,  2,  2,  3,  1,  3,  2 ],
  [  2,  3,  3,  3,  2,  2,  0,  2,  1,  3,  2,  3 ],
  [  3,  2,  1,  3,  3,  2,  2,  0,  3,  3,  2,  2 ],
  [  3,  2,  2,  2,  3,  3,  1,  3,  0,  2,  3,  2 ],
  [  3,  2,  2,  3,  2,  1,  3,  3,  2,  0,  2,  3 ],
  [  3,  2,  3,  1,  2,  3,  2,  2,  3,  2,  0,  3 ],
  [  3,  2,  3,  2,  1,  2,  3,  2,  2,  3,  3,  0 ] ]
gap> R2 := RelationMatrixSortedByClosedSubset(R, [0,1]);;
gap> Display(R2);                                        
[ [  0,  1,  2,  3,  2,  3,  2,  3,  2,  3,  2,  3 ],
  [  1,  0,  3,  2,  3,  2,  3,  2,  3,  2,  3,  2 ],
  [  2,  3,  0,  1,  2,  3,  2,  3,  3,  2,  3,  2 ],
  [  3,  2,  1,  0,  3,  2,  3,  2,  2,  3,  2,  3 ],
  [  2,  3,  2,  3,  0,  1,  3,  2,  2,  3,  3,  2 ],
  [  3,  2,  3,  2,  1,  0,  2,  3,  3,  2,  2,  3 ],
  [  2,  3,  2,  3,  3,  2,  0,  1,  3,  2,  2,  3 ],
  [  3,  2,  3,  2,  2,  3,  1,  0,  2,  3,  3,  2 ],
  [  2,  3,  3,  2,  2,  3,  3,  2,  0,  1,  2,  3 ],
  [  3,  2,  2,  3,  3,  2,  2,  3,  1,  0,  3,  2 ],
  [  2,  3,  3,  2,  3,  2,  2,  3,  2,  3,  0,  1 ],
  [  3,  2,  2,  3,  2,  3,  3,  2,  3,  2,  1,  0 ] ]