Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Have added Wilson's algorithm and loop erased random walks #1576

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

gjh6
Copy link

@gjh6 gjh6 commented Jul 16, 2021

In reference to issue #1571 I have updated LightGraphs with (i) an implementation of Wilson's algorithm, and (ii) an implementation of a loop erased random walk (used by Wilson's algorithm). Both methods have been incorporated into the unit tests. All of the code I have included only calls from the standard library.

For Wilson's, I have implemented the algorithm on a small graph with an easy-to-compute answer, generated a collection of random spanning trees, and then tested that the Monte Carlo scheme was within a tolerance of the exact answer. I repeated this process on a weighted graph. For the loop erased random walks, I have mimicked the tests in traversals/randomwalks (to the extent that it made sense; there are some modifications).

I have mostly kept the code structure the same as the source. There is one small exception, in that I have allowed a user to pass an AbstractRNG as there have been notable deficiencies in the Mersenne Twister although I have performed tests only with this RGN (and found no issues).

In terms of memory use, and with regards to the loop erased random walk, I have attempted to strike a balance between allocation frequency and memory consumption. I have elected to use views as the loop erased random walk may frequently shorten in length and I didn't want to deallocate memory only to immediately reclaim it. This made it natural me to forego using push. When a walk hits the current memory limits, the size of the existing vector is set to the minimum between the doubled length and the number of vertices in the graph. If the maintainers prefer, I am fine to move back to a push!/shorten framework.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant