breadth-first traversal

#11, p. 605:

A={
{0,a,b,c,d,e,f,g,h,i,j},
{a,0,1,1,1,x,x,x,x,x,x},
{b,1,0,1,x,1,x,1,x,x,x},
{c,1,1,0,x,1,1,x,x,x,x},
{d,1,x,x,0,x,1,x,x,x,x},
{e,x,1,1,x,0,1,1,x,x,x},
{f,x,x,1,1,1,0,x,1,x,x},
{g,x,1,x,x,1,x,0,1,x,1},
{h,x,x,x,x,x,1,1,0,1,x},
{i,x,x,x,x,x,x,x,1,0,1},
{j,x,x,x,x,x,x,1,x,1,0}
};
MatrixForm[A]
SymmetricMatrixQ[A]

I can’t believe that Mathematica didn’t have a permutation matrix until version 13.2.... Geez. 
So here’s one I lifted off of stackexchange:

permutationMatrix[i_,j_,n_]:=
IdentityMatrix[n][[#]]&/@PermutationList[Cycles[{{i,j}}],n]

MatrixForm[permutationMatrix[2,4,5]]
MatrixForm[permutationMatrix[1,2,5]]

a has neighbors b,c,d; so they’re up next (no need to permute); but b’s (unmarked) neighbors are e and g: e is in place, but g needs to move into f’s slot (so permute those two rows):

A1=A;
S2=permutationMatrix[7,8,11];
A2=S2.A1.Transpose[S2];
MatrixForm[A2]

c is up next, and it has unmarked neighbor f (which is already in position, so no need to permute). Then d has no unmarked neighbors to contribute.  We then look at e, which also has no unmarked neighbors to contribute; g, however, has two neighbors to contribute: h, which is in position, and then j (so permute i and j):

S2=permutationMatrix[10,11,11];
A3=S2.A2.Transpose[S2];
MatrixForm[A3]

f has no unmarked neighbors, but h does (i): i is in position, so nothing else to do.  The algorithm prints

({{a, b, c, d, e, g, f, h, j, i}})

which we can get by writing out the first row or column!

Practice 14, p. 598:

A={
{0,a,b,c,d,e,f,g,h,i,j,k,l,m},
{a,0,x,x,x,1,1,x,x,x,x,x,x,x},
{b,x,0,1,1,x,x,x,x,x,x,x,x,x},
{c,x,1,0,1,x,x,x,x,x,x,x,x,x},
{d,x,1,1,0,1,x,x,x,1,x,x,x,x},
{e,1,x,x,1,0,1,x,x,1,x,x,x,x},
{f,1,x,x,x,1,0,x,x,1,x,x,x,x},
{g,x,x,x,x,x,x,0,1,1,x,x,x,x},
{h,x,x,x,x,x,x,1,0,1,x,x,1,x},
{i,x,x,x,1,1,1,1,1,0,1,1,x,1},
{j,x,x,x,x,x,x,x,x,1,0,x,x,1},
{k,x,x,x,x,x,x,x,x,1,x,0,1,1},
{l,x,x,x,x,x,x,x,1,x,x,1,0,x},
{m,x,x,x,x,x,x,x,x,1,1,1,x,0}
};
MatrixForm[A]
SymmetricMatrixQ[A]