Zulip Chat Archive

Stream: Is there code for X?

Topic: Walk on SimpleGraph, Consecutive Visits to Vertex Allowed


Fred Rajasekaran (Jul 24 2025 at 03:35):

Is there an easy way to handle walks on a simple graph but allow consecutive visits to the same vertex and have them contribute to the length of the walk? And will I need to define a new inductive type or is there a way to build it on top of the way walks are already defined?

For example if XX is an n×nn \times n matrix and p2p \geq 2 an integer, I want to enumerate the sum on the RHS of

Tr[Xp]=1i1,,ipnXi1i2Xi2i3Xipi1\mathrm{Tr}[X^p] = \sum_{1 \leq i_1, \dots, i_p \leq n}X_{i_1 i_2} X_{i_2 i_3} \dots X_{i_p i_1}

by closed walks of length pp on the complete graph on nn vertices, but I need to allow loops in order to include entries of the form XiiX_{ii} in the sum. I'd like to do this within the SimpleGraph structure since I'll need to change the type of graphs/walks I'm summing over throughout a proof and SimpleGraph seems to have the most API out of all the graphs in lean. I will also eventually rule out having any loops so I will end up with a walk on a simple graph as defined in Combinatorics/SimpleGraph/Walk.lean anyway.

Shreyas Srinivas (Jul 24 2025 at 05:24):

Doesn’t docs#SimpleGraph.Walk already do this?

Shreyas Srinivas (Jul 24 2025 at 05:24):

Oh you want to loop at the same vertex?

Shreyas Srinivas (Jul 24 2025 at 05:25):

I don’t think there is such a structure yet. Most likely because it doesn’t make sense for SimpleGraphs because they are loopless

Laura Monk (Jul 24 2025 at 08:47):

There is now a graph structure which allows for loops so that would be a way, but this is very recent and there is none of the useful tools from simplegraphs yet. I might work on bringing some of these there as I need them for graphs with loops and multiedges myself.


Last updated: Dec 20 2025 at 21:32 UTC