Accessors
This page contains the documentation of the various member functions of the
ToddCoxeter class that can be used to access the state of an instance.
Those functions with the prefix current_ do not perform any further
enumeration.
- ToddCoxeter.complete(self: ToddCoxeter) float
- Returns the proportion of edges defined in the active part of the current word graph. - This function returns the proportion (as a float) of the edges defined. This value is - number_of_edges_activedivided by- number_of_nodes_activemultiplied by- WordGraph.out_degreeapplied to- current_word_graph.- Returns:
- The proportion of edges defined in the active part of - current_word_graph.
- Return type:
 - >>> from libsemigroups_pybind11 import (Presentation, presentation, ToddCoxeter, ... congruence_kind) >>> from datetime import timedelta >>> p = Presentation("bcd") >>> p.contains_empty_word(True) <monoid presentation with 3 letters, 0 rules, and length 0> >>> presentation.add_rule(p, "bb", "") >>> presentation.add_rule(p, "cd", "") >>> presentation.add_rule(p, "ccc", "") >>> presentation.add_rule(p, "bcbcbcbcbcbcbc", "") >>> presentation.add_rule(p, "bcbdbcbdbcbdbc", "") >>> tc = ToddCoxeter(congruence_kind.twosided, p) >>> tc.run() >>> tc.complete() 1.0 
- ToddCoxeter.current_spanning_tree(self: ToddCoxeter) Forest
- Get the current possible spanning tree of the underlying word graph. - This function returns the current value of a possible spanning tree (a - Forest) for the underlying- WordGraph(returned by- current_word_graph). This spanning tree is only populated during calls to- standardizeand as such might contain nothing, or a spanning tree of a previous value of- current_word_graph. Some care should be used with the return value of this function, and it might be better to use the function- spanning_tree, which has none of these limitation. If- Runner.finishedreturns- True, and- standardizehas been called prior to a call to this function, then the returned- Forestwill represent a valid spanning tree for the- WordGraphreturned by- current_word_graphor- word_graph.
- ToddCoxeter.current_word_graph(self: ToddCoxeter) WordGraph
- Get the current word graph. - In some sense, the purpose of the Todd-Coxeter algorithm is to produce a - WordGraphof the action of a set of generators on the classes of a congruence. This function can be used to obtain that- WordGraphas it currently exists within a- ToddCoxeterinstance. This function does not trigger any enumeration.The- WordGraphreturned by this function may be in a rather complicated state. No guarantees are given: about the values of the active nodes (i.e. they may be any non-negative integers in any order); that the number of nodes (including those that are inactive) should coincide with the number of active nodes; that the graph is complete; or that the graph is compatible with the relations of the- presentationor with the generating_pairs. The functions- standardizeand- shrink_to_fitcan be used to modify the returned word graph in-place to have (possibly) more reasonable characteristics.
- ToddCoxeter.is_standardized(*args, **kwargs)
- Overloaded function. - is_standardized(self: ToddCoxeter) bool
- Check if the word graph is currently standardized with respect to any order. This function returns - Trueif the- current_word_graphhas been standardized with respect to the any- Orderother than- Order.none.- Returns:
- Whether or not the current word graph is standardized with respect to any order. 
- Return type:
 
 - is_standardized(self: ToddCoxeter, val: Order) bool
- Check if the word graph is currently standardized with respect to a given order. - This function returns - Trueif the- current_word_graphhas been standardized with respect to the order val ; and- Falseif not.
 
- ToddCoxeter.number_of_edges_active(self: ToddCoxeter) int
- Return the number of edges in the active part of the current word graph. - This function returns the number of edges in the active part of the - current_word_graph. Recall that- current_word_graphcan grow and shrink drastically during a congruence enumeration. As such to avoid unnecessary memory allocations, where possible, the nodes in the- current_word_graphare “recycled” leading to the situation where some of the nodes in- current_word_graphare “active” and others are “inactive”. In other words, the “active” nodes correspond to the part of the word graph that actually represents the classes of the congruence we are trying to enumerate; and the “inactive” nodes are only there to be “recycled” into “active” nodes if they are required later on.- Returns:
- The number of edges that are incident to active nodes. 
- Return type:
 - >>> from libsemigroups_pybind11 import (Presentation, presentation, ToddCoxeter, ... congruence_kind) >>> from datetime import timedelta >>> p = Presentation("bcd") >>> p.contains_empty_word(True) <monoid presentation with 3 letters, 0 rules, and length 0> >>> presentation.add_rule(p, "bb", "") >>> presentation.add_rule(p, "cd", "") >>> presentation.add_rule(p, "ccc", "") >>> presentation.add_rule(p, "bcbcbc", "") >>> presentation.add_rule(p, "bcbdbcbd", "") >>> tc = ToddCoxeter(congruence_kind.twosided, p) >>> tc.number_of_classes() 12 >>> tc.number_of_edges_active() 36 
- ToddCoxeter.number_of_large_collapses(self: ToddCoxeter) int
- Return the number of large collapses that have occurred. - This function returns the number of “large” collapses that have occurred in the graph during any run of a - ToddCoxeterinstance. What qualifies as a “large” collapse can be specified using- large_collapse.- Returns:
- The number of large collapses. 
- Return type:
 - >>> from libsemigroups_pybind11 import (Presentation, presentation, ToddCoxeter, ... congruence_kind) >>> from datetime import timedelta >>> p = Presentation("bcd") >>> p.contains_empty_word(True) <monoid presentation with 3 letters, 0 rules, and length 0> >>> presentation.add_rule(p, "bb", "") >>> presentation.add_rule(p, "cd", "") >>> presentation.add_rule(p, "ccc", "") >>> presentation.add_rule(p, "bcbcbcbcbcbcbc", "") >>> presentation.add_rule(p, "bcbdbcbdbcbdbcbdbcbdbcbdbcbdbcbd", "") >>> tc = ToddCoxeter(congruence_kind.twosided, p) >>> tc.run_for(timedelta(milliseconds=10)) >>> tc.finished() False >>> tc.number_of_large_collapses() 0 
- ToddCoxeter.number_of_nodes_active(self: ToddCoxeter) int
- Return the number of nodes in the active part of the current word graph. - This function returns the number of nodes in the active part of the - current_word_graph. Recall that- current_word_graphcan grow and shrink drastically during a congruence enumeration. As such to avoid unnecessary memory allocations, where possible, the nodes in the- current_word_graphare “recycled” leading to the situation where some of the nodes in- current_word_graphare “active” and others are “inactive”. In other words, the “active” nodes correspond to the part of the word graph that actually represents the classes of the congruence we are trying to enumerate; and the “inactive” nodes are only there to be “recycled” into “active” nodes if they are required later on.- Returns:
- The number of nodes that are active. 
- Return type:
 - >>> from libsemigroups_pybind11 import (Presentation, presentation, ToddCoxeter, ... congruence_kind) >>> from datetime import timedelta >>> p = Presentation("bcd") >>> p.contains_empty_word(True) <monoid presentation with 3 letters, 0 rules, and length 0> >>> presentation.add_rule(p, "bb", "") >>> presentation.add_rule(p, "cd", "") >>> presentation.add_rule(p, "ccc", "") >>> presentation.add_rule(p, "bcbcbc", "") >>> presentation.add_rule(p, "bcbdbcbd", "") >>> tc = ToddCoxeter(congruence_kind.twosided, p) >>> tc.number_of_classes() 12 >>> tc.number_of_nodes_active() 12 
- ToddCoxeter.spanning_tree(self: ToddCoxeter) Forest
- Get the spanning tree of the underlying word graph. This function returns a spanning tree (a - Forest) for the underlying- WordGraph(returned by- word_graph) with the nodes appearing in short-lex order. This function triggers a full congruence enumeration.
- ToddCoxeter.standardization_order(self: ToddCoxeter) Order
- Get the current standardization order of the underlying word graph. - This function returns the standardization order currently used in the underlying word graph. The return value of this function will be the argument of the most recent call to - standardize; or- Order.none.- The return value of this function indicates the following: - Order.noneimplies that no standardization has been performed and:- the return value of - reducewill essentially arbitrary;
- the return values of - todd_coxeter.normal_formsor- todd_coxeter.normal_formswill be essentially arbitrary;
- the classes of the congruence will be indexed in an arbitrary order; 
 
- Order.shortleximplies that:- the return value of - reducewill be the short-lex least word belonging to a given congruence class;
- the return values of - todd_coxeter.normal_formsand- todd_coxeter.normal_formswill be in short-lex order;
- the classes of the congruence will be indexed in short-lex order on the short-lex least word; 
 
- Order.leximplies that:- the return values of - todd_coxeter.normal_formsand- todd_coxeter.normal_formswill be ordered lexicographically.
- the return values of - reduceand the indexes of class are essentially arbitrary because there is not necessarily a lexicographically least word in every class;
 
- Order.recursiveimplies that:- the return value of - reducewill be the recursive path least word belonging to a given congruence class;
- the return values of - todd_coxeter.normal_formsand- todd_coxeter.normal_formswill be ordered by the recursive path order;
- the classes of the congruence will be indexed in recursive path order on the recursive path least word. 
 
 - Returns:
- The current standardization order. 
- Return type:
 
- ToddCoxeter.word_graph(self: ToddCoxeter) WordGraph
- Get the word graph after performing a full congruence enumeration. - In some sense, the purpose of the Todd-Coxeter algorithm is to produce a - WordGraphof the action of a set of generators on the classes of a congruence. This function can be used to obtain that- WordGraphinstance. This function triggers a full enumeration.The- WordGraphreturned by this function may be in a rather complicated state. The active nodes (and nodes) will be \(\{0, \ldots, n - 1\}\) where \(n\) is the number of classes in the congruence if- presentationcontains the empty word; or the number of classes plus one if- presentationdoes not contain the empty word. The returned- WordGraphis also short-lex standardized. The returned- WordGraphwill usually be complete and compatible with the relations of the- presentationand with the- ToddCoxeter.generating_pairs. The- WordGraphmay not be complete or compatible for some values of the settings. For example, if the setting- lower_boundis used but is not the same as the number of classes in the congruence, then the- WordGraphreturned by this function may not be compatible with the relations of- presentationor- ToddCoxeter.generating_pairs.