MHB How many walks of length $n$ can you find on this graph?

  • Thread starter Thread starter Ackbach
  • Start date Start date
  • Tags Tags
    2015
Click For Summary
The discussion revolves around finding the number of walks of length $n$ on a specified graph, with the use of technology permitted for calculations. Participants are encouraged to explain their methods and solutions clearly. The thread highlights that no one has solved the current week's Problem of the Week (POTW) from the University. A user shares their solution, prompting further engagement on the topic. The focus remains on exploring the mathematical approach to counting walks in the graph.
Ackbach
Gold Member
MHB
Messages
4,148
Reaction score
94
Here is this week's POTW:

-----

For the following graph, find the number of walks of length $n$ from any vertex to any other vertex. Use of technology is allowed (but explain what you did and how you did it).

https://www.physicsforums.com/attachments/4470._xfImport

-----

Remember to read the http://www.mathhelpboards.com/showthread.php?772-Problem-of-the-Week-%28POTW%29-Procedure-and-Guidelines to find out how to http://www.mathhelpboards.com/forms.php?do=form&fid=2!
 

Attachments

  • Length_of_Walk_Graph.png
    Length_of_Walk_Graph.png
    5.3 KB · Views: 146
Physics news on Phys.org
No one solved this week's University POTW. Here is my solution.

First, you start with the adjacency matrix, where the $i,j$th entry in the matrix represents the number of paths from vertex $i$ to vertex $j$. Using Mathematica (really Wolfram Programming Cloud), I assigned this as follows:

Code:
A={{0.,1,1,1,1,1},{1,0,1,0,0,0},{1,1,0,2,1,0},{1,0,2,0,2,0},{1,0,1,2,0,1},{1,0,0,0,1,0}} ; A//MatrixForm

The result was

$$\begin{bmatrix}
0. &1 &1 &1 &1 &1 \\
1 &0 &1 &0 &0 &0 \\
1 &1 &0 &2 &1 &1 \\
1 &0 &2 &0 &2 &0 \\
1 &0 &1 &2 &0 &1 \\
1 &0 &0 &0 &1 &0
\end{bmatrix}$$

Because the graph is not directed, this matrix is by necessity symmetric, and therefore diagonalizable.

Further executing the steps

Code:
vecs=Eigenvectors[A]
Diag=Inverse[Transpose[vecs]].A.Transpose[vecs] //Chop;
Diag // Chop // MatrixForm

produced the diagonal matrix similar to $A$. Moreover, as a check,
Code:
Transpose[vecs].Diag.Inverse[Transpose[vecs]] //Chop //MatrixForm
produced $A$ back at me. Note that I introduced decimals to force Wolfram Programming Cloud to recognize the need for numerical computations. Unfortunately, the symbolic approach was far too unwieldy, as finding the eigenvalues involved solving a sixth-order polynomial - not even possible in principle.

Now for the crux of the matter. It can be shown that the $i,j$th entry of $A^n$ gives the number of walks of length $n$ from vertex $i$ to vertex $j$. Hence, this diagonalization is precisely what is needed to compute the $n$th power of $A$. If $D$ is the diagonal matrix similar to $A$ - that is, $A=P^{-1}DP$ for some invertible $P$ - then $A^n=P^{-1}D^n P$, and $D^n$ turns out to be exceptionally easy to compute. All we have to do is exponentiate the main diagonals, and then perform the matrix multiplication indicated to get $A^n$. The result was quite a challenge to display. First the code:

Code:
Transpose[vecs].MatrixPower[Diag,n].Inverse[Transpose[vecs]] //MatrixForm

I had to take six screenshots, one for each row, to get the full results to show up here on MHB. There is far too much text for a single post otherwise. Here they are:

View attachment 4489View attachment 4490View attachment 4491View attachment 4492View attachment 4493View attachment 4494

Once you've attained this result, it's not difficult to get the result for any particular $n$. Just execute (for $n=3$, say) the code

Code:
Transpose[vecs].MatrixPower[Diag,3].Inverse[Transpose[vecs]] //MatrixForm

and you'll get the correct result.
 

Attachments

  • First Row Length of Walk.png
    First Row Length of Walk.png
    25.6 KB · Views: 132
  • Second Row Length of Walk.png
    Second Row Length of Walk.png
    23.3 KB · Views: 108
  • Third Row Length of Walk.png
    Third Row Length of Walk.png
    23.8 KB · Views: 112
  • Fourth Row Length of Walk.png
    Fourth Row Length of Walk.png
    25.6 KB · Views: 130
  • Fifth Row Length of Walk.png
    Fifth Row Length of Walk.png
    24 KB · Views: 127
  • Sixth Row Length of Walk.png
    Sixth Row Length of Walk.png
    23.4 KB · Views: 115

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
1
Views
2K
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K