Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DigraphRandomWalk #543

Merged
merged 1 commit into from
Apr 20, 2022
Merged

Add DigraphRandomWalk #543

merged 1 commit into from
Apr 20, 2022

Conversation

mtorpey
Copy link
Collaborator

@mtorpey mtorpey commented Apr 7, 2022

This adds a new operation that executes a random walk on a graph, starting at a vertex, and having the desired length.

I haven't done doc or tests yet, but does this look like the right sort of thing?

Output is the same as DigraphPath: a pair [v,a] where

  • v is the ordered list of vertices in the path;
  • a is the list of indices of edges followed from each vertex (helps distinguish edges in multidigraphs).
gap> D := Digraph([[1, 2], [3], [2, 4], [1], [2, 4]]);                
<immutable digraph with 5 vertices, 8 edges>
gap> DigraphRandomWalk(D, 1, 4);
[ [ 1, 2, 3, 2, 3 ], [ 2, 1, 1, 1 ] ]

If we reach a sink, we cut the path short, so the final length might be less than requested.

@mtorpey mtorpey added enhancement A label for PRs that provide enhancements. WIP Label of PRs that are a Work In Progress (WIP) labels Apr 7, 2022
@mtorpey mtorpey requested review from james-d-mitchell and flsmith and removed request for james-d-mitchell and flsmith April 7, 2022 17:27
@mtorpey mtorpey force-pushed the add-random-walks branch 2 times, most recently from 8edb223 to a7ed3d6 Compare April 8, 2022 13:04
@mtorpey mtorpey requested a review from flsmith April 13, 2022 13:17
@flsmith
Copy link
Collaborator

flsmith commented Apr 13, 2022

As discussed, Michael plans to rename this length to something less expectation-loaded which forces users to read the documentation, so that surprises from shorter-length paths being returned are minimised.

@mtorpey mtorpey removed the WIP Label of PRs that are a Work In Progress (WIP) label Apr 13, 2022
@mtorpey
Copy link
Collaborator Author

mtorpey commented Apr 13, 2022

@flsmith: This is ready for merging (as far as I can tell!)

Copy link
Collaborator

@flsmith flsmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@mtorpey mtorpey merged commit 69a6d9d into digraphs:master Apr 20, 2022
@mtorpey mtorpey deleted the add-random-walks branch April 20, 2022 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A label for PRs that provide enhancements.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants