Skip to content

Commit 5daf425

Browse files
codexjames-d-mitchell
authored andcommitted
froidure-pin: add dot_right/left_cayley_graph
1 parent 6f5c03c commit 5daf425

3 files changed

Lines changed: 205 additions & 0 deletions

File tree

src/froidure-pin-base.cpp

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
//
1818

1919
// libsemigroups headers
20+
#include <libsemigroups/dot.hpp>
2021
#include <libsemigroups/froidure-pin-base.hpp>
2122

2223
// pybind11....
@@ -528,6 +529,164 @@ Returns the position of the suffix of the element ``x`` in position *pos*
528529
py::options options;
529530
options.disable_function_signatures();
530531

532+
m.def("froidure_pin_dot_current_right_cayley_graph",
533+
py::overload_cast<FroidurePinBase const&>(
534+
&froidure_pin::dot_current_right_cayley_graph),
535+
py::arg("fp"),
536+
R"pbdoc(
537+
:sig=(fp: FroidurePin) -> Dot:
538+
539+
Returns a :any:`Dot` object representing the current right Cayley graph.
540+
541+
This function does not trigger a full enumeration of *fp*.
542+
543+
:param fp: the :any:`FroidurePin` object.
544+
:type fp: FroidurePin
545+
546+
:returns: A :any:`Dot` object.
547+
:rtype: Dot
548+
)pbdoc");
549+
550+
m.def("froidure_pin_dot_current_right_cayley_graph",
551+
py::overload_cast<FroidurePinBase const&, std::string const&>(
552+
&froidure_pin::dot_current_right_cayley_graph),
553+
py::arg("fp"),
554+
py::arg("gen_names"),
555+
R"pbdoc(
556+
:sig=(fp: FroidurePin, gen_names: str) -> Dot:
557+
558+
Returns a :any:`Dot` object representing the current right Cayley graph.
559+
560+
The generators are labelled using the characters in *gen_names*.
561+
562+
:param fp: the :any:`FroidurePin` object.
563+
:type fp: FroidurePin
564+
:param gen_names: the labels for the generators.
565+
:type gen_names: str
566+
567+
:returns: A :any:`Dot` object.
568+
:rtype: Dot
569+
)pbdoc");
570+
571+
m.def("froidure_pin_dot_right_cayley_graph",
572+
py::overload_cast<FroidurePinBase&>(
573+
&froidure_pin::dot_right_cayley_graph),
574+
py::arg("fp"),
575+
R"pbdoc(
576+
:sig=(fp: FroidurePin) -> Dot:
577+
578+
Returns a :any:`Dot` object representing the right Cayley graph.
579+
580+
This function triggers a full enumeration of *fp*.
581+
582+
:param fp: the :any:`FroidurePin` object.
583+
:type fp: FroidurePin
584+
585+
:returns: A :any:`Dot` object.
586+
:rtype: Dot
587+
)pbdoc");
588+
589+
m.def("froidure_pin_dot_right_cayley_graph",
590+
py::overload_cast<FroidurePinBase&, std::string const&>(
591+
&froidure_pin::dot_right_cayley_graph),
592+
py::arg("fp"),
593+
py::arg("gen_names"),
594+
R"pbdoc(
595+
:sig=(fp: FroidurePin, gen_names: str) -> Dot:
596+
597+
Returns a :any:`Dot` object representing the right Cayley graph.
598+
599+
This function triggers a full enumeration of *fp*. The generators are labelled
600+
using the characters in *gen_names*.
601+
602+
:param fp: the :any:`FroidurePin` object.
603+
:type fp: FroidurePin
604+
:param gen_names: the labels for the generators.
605+
:type gen_names: str
606+
607+
:returns: A :any:`Dot` object.
608+
:rtype: Dot
609+
)pbdoc");
610+
611+
m.def("froidure_pin_dot_current_left_cayley_graph",
612+
py::overload_cast<FroidurePinBase const&>(
613+
&froidure_pin::dot_current_left_cayley_graph),
614+
py::arg("fp"),
615+
R"pbdoc(
616+
:sig=(fp: FroidurePin) -> Dot:
617+
618+
Returns a :any:`Dot` object representing the current left Cayley graph.
619+
620+
This function does not trigger a full enumeration of *fp*.
621+
622+
:param fp: the :any:`FroidurePin` object.
623+
:type fp: FroidurePin
624+
625+
:returns: A :any:`Dot` object.
626+
:rtype: Dot
627+
)pbdoc");
628+
629+
m.def("froidure_pin_dot_current_left_cayley_graph",
630+
py::overload_cast<FroidurePinBase const&, std::string const&>(
631+
&froidure_pin::dot_current_left_cayley_graph),
632+
py::arg("fp"),
633+
py::arg("gen_names"),
634+
R"pbdoc(
635+
:sig=(fp: FroidurePin, gen_names: str) -> Dot:
636+
637+
Returns a :any:`Dot` object representing the current left Cayley graph.
638+
639+
The generators are labelled using the characters in *gen_names*.
640+
641+
:param fp: the :any:`FroidurePin` object.
642+
:type fp: FroidurePin
643+
:param gen_names: the labels for the generators.
644+
:type gen_names: str
645+
646+
:returns: A :any:`Dot` object.
647+
:rtype: Dot
648+
)pbdoc");
649+
650+
m.def("froidure_pin_dot_left_cayley_graph",
651+
py::overload_cast<FroidurePinBase&>(
652+
&froidure_pin::dot_left_cayley_graph),
653+
py::arg("fp"),
654+
R"pbdoc(
655+
:sig=(fp: FroidurePin) -> Dot:
656+
657+
Returns a :any:`Dot` object representing the left Cayley graph.
658+
659+
This function triggers a full enumeration of *fp*.
660+
661+
:param fp: the :any:`FroidurePin` object.
662+
:type fp: FroidurePin
663+
664+
:returns: A :any:`Dot` object.
665+
:rtype: Dot
666+
)pbdoc");
667+
668+
m.def("froidure_pin_dot_left_cayley_graph",
669+
py::overload_cast<FroidurePinBase&, std::string const&>(
670+
&froidure_pin::dot_left_cayley_graph),
671+
py::arg("fp"),
672+
py::arg("gen_names"),
673+
R"pbdoc(
674+
:sig=(fp: FroidurePin, gen_names: str) -> Dot:
675+
676+
Returns a :any:`Dot` object representing the left Cayley graph.
677+
678+
This function triggers a full enumeration of *fp*. The generators are labelled
679+
using the characters in *gen_names*.
680+
681+
:param fp: the :any:`FroidurePin` object.
682+
:type fp: FroidurePin
683+
:param gen_names: the labels for the generators.
684+
:type gen_names: str
685+
686+
:returns: A :any:`Dot` object.
687+
:rtype: Dot
688+
)pbdoc");
689+
531690
m.def("froidure_pin_product_by_reduction",
532691
&froidure_pin::product_by_reduction,
533692
py::arg("fp"),

src/libsemigroups_pybind11/froidure_pin.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@
7171
Transf1 as _Transf1,
7272
Transf2 as _Transf2,
7373
Transf4 as _Transf4,
74+
froidure_pin_dot_current_left_cayley_graph as _froidure_pin_dot_current_left_cayley_graph,
75+
froidure_pin_dot_current_right_cayley_graph as _froidure_pin_dot_current_right_cayley_graph,
76+
froidure_pin_dot_left_cayley_graph as _froidure_pin_dot_left_cayley_graph,
77+
froidure_pin_dot_right_cayley_graph as _froidure_pin_dot_right_cayley_graph,
7478
froidure_pin_current_minimal_factorisation as _froidure_pin_current_minimal_factorisation,
7579
froidure_pin_current_normal_forms as _froidure_pin_current_normal_forms,
7680
froidure_pin_current_position as _froidure_pin_current_position,
@@ -261,6 +265,10 @@ def sorted_elements( # pylint: disable=missing-function-docstring
261265
# TODO(1) be good to get the notes about enumeration being triggered or not, in
262266
# this doc
263267

268+
dot_current_left_cayley_graph = _wrap_cxx_free_fn(_froidure_pin_dot_current_left_cayley_graph)
269+
dot_current_right_cayley_graph = _wrap_cxx_free_fn(_froidure_pin_dot_current_right_cayley_graph)
270+
dot_left_cayley_graph = _wrap_cxx_free_fn(_froidure_pin_dot_left_cayley_graph)
271+
dot_right_cayley_graph = _wrap_cxx_free_fn(_froidure_pin_dot_right_cayley_graph)
264272
current_minimal_factorisation = _wrap_cxx_free_fn(_froidure_pin_current_minimal_factorisation)
265273
current_normal_forms = _wrap_cxx_free_fn(_froidure_pin_current_normal_forms)
266274
current_position = _wrap_cxx_free_fn(_froidure_pin_current_position)

tests/test_froidure_pin.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
UNDEFINED,
1919
Bipartition,
2020
BMat8,
21+
Dot,
2122
FroidurePin,
2223
KnuthBendix,
2324
LibsemigroupsError,
@@ -161,13 +162,50 @@ def check_idempotents(S):
161162
def check_cayley_graphs(S):
162163
ReportGuard(False)
163164

165+
gen_names = "abcdefghijklmnopqrstuvwxyz"[: S.number_of_generators()]
166+
167+
d = froidure_pin.dot_current_right_cayley_graph(S)
168+
assert isinstance(d, Dot)
169+
assert d.kind() == Dot.Kind.digraph
170+
assert len(d.nodes()) == S.current_size()
171+
172+
d = froidure_pin.dot_current_right_cayley_graph(S, gen_names)
173+
assert isinstance(d, Dot)
174+
assert len(d.nodes()) == S.current_size()
175+
176+
d = froidure_pin.dot_current_left_cayley_graph(S)
177+
assert isinstance(d, Dot)
178+
assert d.kind() == Dot.Kind.digraph
179+
assert len(d.nodes()) == S.current_size()
180+
181+
d = froidure_pin.dot_current_left_cayley_graph(S, gen_names)
182+
assert isinstance(d, Dot)
183+
assert len(d.nodes()) == S.current_size()
184+
164185
g = S.right_cayley_graph()
165186
assert g.number_of_nodes() == S.size()
166187
assert g.out_degree() == S.number_of_generators()
188+
189+
d = froidure_pin.dot_right_cayley_graph(S)
190+
assert isinstance(d, Dot)
191+
assert len(d.nodes()) == S.size()
192+
193+
d = froidure_pin.dot_right_cayley_graph(S, gen_names)
194+
assert isinstance(d, Dot)
195+
assert len(d.nodes()) == S.size()
196+
167197
g = S.left_cayley_graph()
168198
assert g.number_of_nodes() == S.size()
169199
assert g.out_degree() == S.number_of_generators()
170200

201+
d = froidure_pin.dot_left_cayley_graph(S)
202+
assert isinstance(d, Dot)
203+
assert len(d.nodes()) == S.size()
204+
205+
d = froidure_pin.dot_left_cayley_graph(S, gen_names)
206+
assert isinstance(d, Dot)
207+
assert len(d.nodes()) == S.size()
208+
171209

172210
def check_factor_prod_rels(S):
173211
ReportGuard(False)

0 commit comments

Comments
 (0)