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.
Contents
Class for iterating through paths in a |
|
|
Check if the range is exhausted. |
|
Copy a |
|
Get the size of the range. |
Get the current target node of the path labelled by |
|
|
Get the current path in the range. |
|
Reinitialize a |
|
Overloaded function. |
|
Overloaded function. |
|
Advance to the next path in the range. |
|
Overloaded function. |
|
Overloaded function. |
|
Overloaded function. |
The underlying word graph. |
Full API
- class Paths
- __init__(self: Paths, wg: WordGraph) None
Construct from a
WordGraph.This function constructs a
Pathsobject from theWordGraphwg.- Parameters:
wg (WordGraph) – the word graph.
- at_end(self: Paths) bool
Check if the range is exhausted. This function returns
Trueif there are no more paths in the range, andFalseotherwise.- Returns:
Whether or not the range is exhausted.
- Return type:
- Raises:
LibsemigroupsError – if
source() == UNDEFINED.
- 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
nextis called then the return value ofcountdecreases by1).- Returns:
The number of paths remaining in the range.
- Return type:
- 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 byPaths.get. If there is no such path (because, for example, the source node hasn’t been defined, thenUNDEFINEDis returned).
- get(self: Paths) list[int]
Get the current path in the range.
- Returns:
The current path.
- Return type:
- Raises:
LibsemigroupsError – if
source() == UNDEFINED.
- init(self: Paths, wg: WordGraph) Paths
Reinitialize a
Pathsobject.This function puts a
Pathsobject back into the same state as if it had been newly constructs from theWordGraphwg.
- 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:
- 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:
- 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:
- next(self: Paths) None
Advance to the next path in the range. Advance to the current path in the range. If
at_endreturnsTrue, 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
Pathsobject. The initial value isOrder.shortlex.- Returns:
The order of the paths in the range.
- Return type:
- 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
Pathsobject. The initial value isOrder.shortlex.- Parameters:
val (Order) – the order of the paths in the range.
- Returns:
self.
- Return type:
- Raises:
LibsemigroupsError – if val is not
Order.shortlexorOrder.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
Pathsobject. This initial value isUNDEFINED.- Returns:
The current source node.
- Return type:
- 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:
- 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
Pathsobject. This initial value isUNDEFINED.- Returns:
The target node.
- Return type:
- 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 fromsourceto every possible target in the underlyingWordGraph(word_graph).- Parameters:
n (int) – the target node.
- Returns:
self.
- Return type:
- Raises:
LibsemigroupsError – if n is not a node in the underlying
WordGraph(word_graph) and n is notUNDEFINED.