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

  • MHB
  • Thread starter Ackbach
  • Start date
  • Tags
    2015
In summary, a walk of length $n$ on a graph is defined as a sequence of $n$ vertices where each consecutive vertex is connected by an edge. This walk can visit the same vertex multiple times, but cannot repeat the same edge in the same direction more than once. To find all the walks of length $n$ on a graph, one can start at any vertex and use algorithms such as depth-first search or breadth-first search to explore all possible paths. In most cases, the number of walks of length $n$ on a graph is finite, but if the graph contains cycles, there may be infinitely many walks of length $n$ that visit the same set of vertices in different orders. The number of walks of length
  • #1
Ackbach
Gold Member
MHB
4,155
89
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: 100
Physics news on Phys.org
  • #2
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: 80
  • Second Row Length of Walk.png
    Second Row Length of Walk.png
    23.3 KB · Views: 73
  • Third Row Length of Walk.png
    Third Row Length of Walk.png
    23.8 KB · Views: 76
  • Fourth Row Length of Walk.png
    Fourth Row Length of Walk.png
    25.6 KB · Views: 73
  • Fifth Row Length of Walk.png
    Fifth Row Length of Walk.png
    24 KB · Views: 80
  • Sixth Row Length of Walk.png
    Sixth Row Length of Walk.png
    23.4 KB · Views: 73

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

1. How are walks of length $n$ defined on a graph?

A walk of length $n$ on a graph is a sequence of $n$ vertices, where each vertex in the sequence is adjacent to the next vertex. This means that there is an edge connecting each pair of consecutive vertices in the sequence.

2. Can a walk of length $n$ visit the same vertex more than once?

Yes, a walk of length $n$ can visit the same vertex multiple times. However, it cannot repeat the same edge in the same direction more than once.

3. How can you find all the walks of length $n$ on a graph?

To find all the walks of length $n$ on a graph, you can start at any vertex and systematically explore all possible paths of length $n$ from that vertex. This can be done using algorithms such as depth-first search or breadth-first search.

4. Is the number of walks of length $n$ on a graph finite?

In most cases, the number of walks of length $n$ on a graph is finite. However, if the graph contains cycles, there may be infinitely many walks of length $n$ that visit the same set of vertices in different orders.

5. How do you calculate the number of walks of length $n$ on a graph?

The number of walks of length $n$ on a graph can be calculated using the adjacency matrix of the graph. The number of walks of length $n$ starting from a particular vertex is given by the sum of the $n$th powers of the entries in the corresponding row of the adjacency matrix. The total number of walks of length $n$ on the graph can be found by summing up the number of walks starting from all vertices in the graph.

Similar threads

Replies
1
Views
2K
  • Math POTW for University Students
Replies
1
Views
1K
  • Math POTW for University Students
Replies
1
Views
1K
  • Math POTW for University Students
Replies
1
Views
1K
  • Math POTW for University Students
Replies
1
Views
1K
Replies
1
Views
1K
  • Math POTW for University Students
Replies
1
Views
1K
  • Math POTW for University Students
Replies
1
Views
1K
  • Math POTW for University Students
Replies
1
Views
2K
Back
Top