Skip to main content

Module walk

Module walk 

Source
Expand description

Walking a chain: from a start, on to the one next node, and the one after that, until the chain closes, ends, or runs into itself — a loop of coedges followed round its face, a tangent chain of edges, the arcs of one circle, a sketch’s curves joined end to end, a pattern’s joints driving each other.

What comes next is the caller’s (next, which may refuse with an error where the chain forks); the walk promises to tell the three ways a chain can end apart, and to end: no node is walked twice, so a walk over finitely many nodes ends after at most that many steps, whatever next does. A chain that runs into itself somewhere other than its start is reported as such, never followed round again.

flood is the walk of a graph rather than a chain: from some nodes to every node reachable from them, each visited once.

Structs§

Walk
A walk: its nodes in order, the start first, and how it ended.

Enums§

Take
Which pending node a flood visits next.
Walked
How a walk ended.

Functions§

flood
Visits starts and every node reachable from them, each once: visit is asked for each node in turn, and hands on its neighbours, in order; a node not handed on before joins the pending ones, and which of those comes next take says. Returns the nodes in the order visited.
walk
walk_by for nodes that are their own keys.
walk_by
Walks from start along next: the node after each, or None where there is none. Nodes are told apart by key: a node with the key of the start closes the chain, one with the key of a node walked since runs into it. next is asked once for each node, in order, so it may keep state of its own.