The Paths class

Class for iterating through paths in a WordGraph.

This class represents a range object that facilitates iterating through the paths in a WordGraph from a given source (to a possible target node) in a particular order.

Note

Changing the value of source, target, min, max, or order resets the Paths object to point at the first word in the specified range.

Contents

Paths

Class for iterating through paths in a WordGraph.

Paths.at_end(…)

Check if the range is exhausted.

Paths.copy(…)

Copy a Paths object.

Paths.count(…)

Get the size of the range.

Paths.current_target(…)

Get the current target node of the path labelled by Paths.get.

Paths.get(…)

Get the current path in the range.

Paths.init(…)

Reinitialize a Paths object.

Paths.max(…)

Overloaded function.

Paths.min(…)

Overloaded function.

Paths.next(…)

Advance to the next path in the range.

Paths.order(…)

Overloaded function.

Paths.source(…)

Overloaded function.

Paths.target(…)

Overloaded function.

Paths.word_graph(…)

The underlying word graph.

Full API

class Paths
__init__(self: Paths, wg: WordGraph) None

Construct from a WordGraph.

This function constructs a Paths object from the WordGraph wg.

Parameters:

wg (WordGraph) – the word graph.

at_end(self: Paths) bool

Check if the range is exhausted. This function returns True if there are no more paths in the range, and False otherwise.

Returns:

Whether or not the range is exhausted.

Return type:

bool

Raises:

LibsemigroupsError – if source() == UNDEFINED.

copy(self: Paths) Paths

Copy a Paths object.

Returns:

A copy.

Return type:

Paths

count(self: Paths) int | PositiveInfinity

Get the size of the range. This function returns the number of paths remaining in the range (in particular, if next is called then the return value of count decreases by 1).

Returns:

The number of paths remaining in the range.

Return type:

int | PositiveInfinity

Raises:

LibsemigroupsError – if source() == UNDEFINED.

current_target(self: Paths) int

Get the current target node of the path labelled by Paths.get. This function returns the current target node of the path labelled by Paths.get. If there is no such path (because, for example, the source node hasn’t been defined, then UNDEFINED is returned).

Returns:

The current target node of the path labelled by Paths.get or UNDEFINED.

Return type:

int

get(self: Paths) list[int]

Get the current path in the range.

Returns:

The current path.

Return type:

list[int]

Raises:

LibsemigroupsError – if source() == UNDEFINED.

init(self: Paths, wg: WordGraph) Paths

Reinitialize a Paths object.

This function puts a Paths object back into the same state as if it had been newly constructs from the WordGraph wg.

Parameters:

wg (WordGraph) – the word graph.

Returns:

self

Return type:

Paths

max(*args, **kwargs)

Overloaded function.

max(self: Paths) int | PositiveInfinity

Get the maximum length of path in the range.

This function returns the current maximum length of paths in the range. The initial value is POSITIVE_INFINITY.

Returns:

The maximum length of paths in the range.

Return type:

int | PositiveInfinity

max(self: Paths, val: int | PositiveInfinity) Paths

Set the maximum length of path in the range.

This function can be used to set the maximum length of path that will be contained in the range. If this function is not called, then the range will contain paths of unbounded length (possibly infinitely many).

Parameters:

val (int | PositiveInfinity) – the maximum path length.

Returns:

self.

Return type:

Paths

min(self: Paths, val: int) Paths

Overloaded function.

min(self: Paths) int

Get the minimum length of path in the range. This function returns the current minimum length of paths in the range. The initial value is 0.

Returns:

The minimum length of paths in the range.

Return type:

int

min(self: Paths, val: int) Paths

Set the minimum length of path in the range.

This function can be used to set the minimum length of paths that will be contained in the range. If this function is not called, then the range will contain paths starting with length 0.

Parameters:

val (int) – the minimum path length.

Returns:

self.

Return type:

Paths

next(self: Paths) None

Advance to the next path in the range. Advance to the current path in the range. If at_end returns True, then this function does nothing.

Raises:

LibsemigroupsError – if source() == UNDEFINED.

order(*args, **kwargs)

Overloaded function.

order(self: Paths) Order

Get the order of the paths in the range. This function returns the current order of the paths in the range defined by a Paths object. The initial value is Order.shortlex.

Returns:

The order of the paths in the range.

Return type:

Order

order(self: Paths, val: Order) Paths

Set the order of the paths in the range.

This function can be used to set the order of the paths in the range defined by a Paths object. The initial value is Order.shortlex.

Parameters:

val (Order) – the order of the paths in the range.

Returns:

self.

Return type:

Paths

Raises:

LibsemigroupsError – if val is not Order.shortlex or Order.lex.

source(self: Paths, n: int) Paths

Overloaded function.

source(self: Paths) int

Get the current source node of every path in the range. This function returns the current source node of the every path in the range defined by a Paths object. This initial value is UNDEFINED.

Returns:

The current source node.

Return type:

int

source(self: Paths, n: int) Paths

Set the source node of every path in the range.

This function can be used to set the source node of all of the paths in the range.

Parameters:

n (int) – the source node.

Returns:

self.

Return type:

Paths

Raises:

LibsemigroupsError – if n is not a node in the underlying WordGraph (word_graph).

target(self: Paths, n: int) Paths

Overloaded function.

target(self: Paths) int

Get the current target node of every path in the range. This function returns the target node of the every path in the range defined by a Paths object. This initial value is UNDEFINED.

Returns:

The target node.

Return type:

int

target(self: Paths, n: int) Paths

Set the target node of every path in the range.

This function can be used to set the target node (or the “to” node) of all of the paths in the range. It is not necessary to set this value. If the target node is set to UNDEFINED, then the range will contain every path from source to every possible target in the underlying WordGraph (word_graph).

Parameters:

n (int) – the target node.

Returns:

self.

Return type:

Paths

Raises:

LibsemigroupsError – if n is not a node in the underlying WordGraph (word_graph) and n is not UNDEFINED.

word_graph(self: Paths) WordGraph

The underlying word graph. This function returns underlying WordGraph of the Paths object. This is the WordGraph defining the paths in the range.

Returns:

The underlying word graph.

Return type:

WordGraph