Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 70 additions & 32 deletions src/dot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,67 @@ its DOT_ source code string (:any:`Dot.to_string`). Write the source code to a
file and render it with the Graphviz_ installation on your system.
)pbdoc");

////////////////////////////////////////////////////////////////////////////
// Attr enum
////////////////////////////////////////////////////////////////////////////

py::options options;
options.disable_enum_members_docstring();

py::enum_<Dot::Attr> attr(dot, "Attr", R"pbdoc(
The values in this enum can be used to indicate how attribute values are
written in the DOT_ output.

The valid values are:

.. py:attribute:: Attr.string
:value: <Attr.string: 0>

Value indicating that the attribute value should be written as a quoted
string.

.. py:attribute:: Attr.html
:value: <Attr.html: 1>

Value indicating that the attribute value should be written as an HTML-like
label.
)pbdoc");
attr.value("string", Dot::Attr::string).value("html", Dot::Attr::html);
attr.def("__repr__", [](Dot::Attr const& val) {
return to_human_readable_repr(val, ".");
});

////////////////////////////////////////////////////////////////////////////
// Kind enum
////////////////////////////////////////////////////////////////////////////

py::enum_<Dot::Kind> kind(dot, "Kind", R"pbdoc(
The values in this enum can be used to indicate the type of a graph.

The valid values are:

.. py:attribute:: Kind.digraph
:value: <Kind.digraph: 0>

Value indicating that the represented graph has directed edges ->.

.. py:attribute:: Kind.graph
:value: <Kind.graph: 1>

Value indicating that the represented graph has undirected edges --.

.. py:attribute:: Kind.subgraph
:value: <Kind.subgraph: 2>

Value indicating that the represented graph is a subgraph of another Dot object.
)pbdoc");
kind.value("digraph", Dot::Kind::digraph)
.value("graph", Dot::Kind::graph)
.value("subgraph", Dot::Kind::subgraph);
kind.def("__repr__", [](Dot::Kind const& knd) {
return to_human_readable_repr(knd, ".");
});

////////////////////////////////////////////////////////////////////////////
// Node nested class
////////////////////////////////////////////////////////////////////////////
Expand All @@ -74,6 +135,7 @@ The name of the node.
&Dot::Node::add_attr<std::string const&, std::string const&>,
py::arg("key"),
py::arg("val"),
py::arg("kind") = Dot::Attr::string,
R"pbdoc(Add an attribute to a node.

This function adds a new attribute, or replaces the value of an existing
Expand All @@ -83,6 +145,8 @@ attribute of a :any:`Dot.Node`.
:type key: str
:param val: the value of the attribute.
:type val: str
:param kind: whether to add quotes to *val* or not.
:type val: Dot.Attr

:returns: *self*
:rtype: Dot.Node
Expand Down Expand Up @@ -121,6 +185,7 @@ The name (read-only `str`) of the tail of the edge.
&Dot::Edge::add_attr<std::string const&, std::string const&>,
py::arg("key"),
py::arg("val"),
py::arg("kind") = Dot::Attr::string,
R"pbdoc(Add an attribute to an edge.

This function adds a new attribute, or replaces the value of an existing
Expand All @@ -130,43 +195,13 @@ attribute of an :any:`Edge`.
:type key: str
:param val: the value of the attribute.
:type val: str
:param kind: whether to add quotes to *val* or not.
:type val: Dot.Attr

:returns: *self*
:rtype: Dot.Edge
)pbdoc");

////////////////////////////////////////////////////////////////////////////
// Kind enum
////////////////////////////////////////////////////////////////////////////
py::options options;
options.disable_enum_members_docstring();
py::enum_<Dot::Kind> kind(dot, "Kind", R"pbdoc(
The values in this enum can be used to indicate the type of a graph.

The valid values are:

.. py:attribute:: Kind.digraph
:value: <Kind.digraph: 0>

Value indicating that the represented graph has directed edges ->.

.. py:attribute:: Kind.graph
:value: <Kind.graph: 1>

Value indicating that the represented graph has undirected edges --.

.. py:attribute:: Kind.subgraph
:value: <Kind.subgraph: 2>

Value indicating that the represented graph is a subgraph of another Dot object.
)pbdoc");
kind.value("digraph", Dot::Kind::digraph)
.value("graph", Dot::Kind::graph)
.value("subgraph", Dot::Kind::subgraph);
kind.def("__repr__", [](Dot::Kind const& knd) {
return to_human_readable_repr(knd, ".");
});

////////////////////////////////////////////////////////////////////////////
// Dot members
////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -474,6 +509,7 @@ representation of the graph in the DOT_ language for Graphviz_.
&Dot::add_attr<std::string const&, std::string const&>,
py::arg("key"),
py::arg("val"),
py::arg("kind") = Dot::Attr::string,
R"pbdoc(Add an attribute to a :any:`Dot` object.

This function adds a new attribute, or replaces the value of an existing
Expand All @@ -483,6 +519,8 @@ attribute of an :any:`Dot`.
:type key: str
:param val: the value of the attribute.
:type val: str
:param kind: whether to add quotes to *val* or not.
:type val: Dot.Attr

:returns: *self*
:rtype: Dot
Expand Down
159 changes: 159 additions & 0 deletions src/froidure-pin-base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
//

// libsemigroups headers
#include <libsemigroups/dot.hpp>
#include <libsemigroups/froidure-pin-base.hpp>

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

m.def("froidure_pin_dot_current_right_cayley_graph",
py::overload_cast<FroidurePinBase const&>(
&froidure_pin::dot_current_right_cayley_graph),
py::arg("fp"),
R"pbdoc(
:sig=(fp: FroidurePin) -> Dot:

Returns a :any:`Dot` object representing the current right Cayley graph.

This function does not trigger a full enumeration of *fp*.

:param fp: the :any:`FroidurePin` object.
:type fp: FroidurePin

:returns: A :any:`Dot` object.
:rtype: Dot
)pbdoc");

m.def("froidure_pin_dot_current_right_cayley_graph",
py::overload_cast<FroidurePinBase const&, std::string const&>(
&froidure_pin::dot_current_right_cayley_graph),
py::arg("fp"),
py::arg("gen_names"),
R"pbdoc(
:sig=(fp: FroidurePin, gen_names: str) -> Dot:

Returns a :any:`Dot` object representing the current right Cayley graph.

The generators are labelled using the characters in *gen_names*.

:param fp: the :any:`FroidurePin` object.
:type fp: FroidurePin
:param gen_names: the labels for the generators.
:type gen_names: str

:returns: A :any:`Dot` object.
:rtype: Dot
)pbdoc");

m.def("froidure_pin_dot_right_cayley_graph",
py::overload_cast<FroidurePinBase&>(
&froidure_pin::dot_right_cayley_graph),
py::arg("fp"),
R"pbdoc(
:sig=(fp: FroidurePin) -> Dot:

Returns a :any:`Dot` object representing the right Cayley graph.

This function triggers a full enumeration of *fp*.

:param fp: the :any:`FroidurePin` object.
:type fp: FroidurePin

:returns: A :any:`Dot` object.
:rtype: Dot
)pbdoc");

m.def("froidure_pin_dot_right_cayley_graph",
py::overload_cast<FroidurePinBase&, std::string const&>(
&froidure_pin::dot_right_cayley_graph),
py::arg("fp"),
py::arg("gen_names"),
R"pbdoc(
:sig=(fp: FroidurePin, gen_names: str) -> Dot:

Returns a :any:`Dot` object representing the right Cayley graph.

This function triggers a full enumeration of *fp*. The generators are labelled
using the characters in *gen_names*.

:param fp: the :any:`FroidurePin` object.
:type fp: FroidurePin
:param gen_names: the labels for the generators.
:type gen_names: str

:returns: A :any:`Dot` object.
:rtype: Dot
)pbdoc");

m.def("froidure_pin_dot_current_left_cayley_graph",
py::overload_cast<FroidurePinBase const&>(
&froidure_pin::dot_current_left_cayley_graph),
py::arg("fp"),
R"pbdoc(
:sig=(fp: FroidurePin) -> Dot:

Returns a :any:`Dot` object representing the current left Cayley graph.

This function does not trigger a full enumeration of *fp*.

:param fp: the :any:`FroidurePin` object.
:type fp: FroidurePin

:returns: A :any:`Dot` object.
:rtype: Dot
)pbdoc");

m.def("froidure_pin_dot_current_left_cayley_graph",
py::overload_cast<FroidurePinBase const&, std::string const&>(
&froidure_pin::dot_current_left_cayley_graph),
py::arg("fp"),
py::arg("gen_names"),
R"pbdoc(
:sig=(fp: FroidurePin, gen_names: str) -> Dot:

Returns a :any:`Dot` object representing the current left Cayley graph.

The generators are labelled using the characters in *gen_names*.

:param fp: the :any:`FroidurePin` object.
:type fp: FroidurePin
:param gen_names: the labels for the generators.
:type gen_names: str

:returns: A :any:`Dot` object.
:rtype: Dot
)pbdoc");

m.def("froidure_pin_dot_left_cayley_graph",
py::overload_cast<FroidurePinBase&>(
&froidure_pin::dot_left_cayley_graph),
py::arg("fp"),
R"pbdoc(
:sig=(fp: FroidurePin) -> Dot:

Returns a :any:`Dot` object representing the left Cayley graph.

This function triggers a full enumeration of *fp*.

:param fp: the :any:`FroidurePin` object.
:type fp: FroidurePin

:returns: A :any:`Dot` object.
:rtype: Dot
)pbdoc");

m.def("froidure_pin_dot_left_cayley_graph",
py::overload_cast<FroidurePinBase&, std::string const&>(
&froidure_pin::dot_left_cayley_graph),
py::arg("fp"),
py::arg("gen_names"),
R"pbdoc(
:sig=(fp: FroidurePin, gen_names: str) -> Dot:

Returns a :any:`Dot` object representing the left Cayley graph.

This function triggers a full enumeration of *fp*. The generators are labelled
using the characters in *gen_names*.

:param fp: the :any:`FroidurePin` object.
:type fp: FroidurePin
:param gen_names: the labels for the generators.
:type gen_names: str

:returns: A :any:`Dot` object.
:rtype: Dot
)pbdoc");

m.def("froidure_pin_product_by_reduction",
&froidure_pin::product_by_reduction,
py::arg("fp"),
Expand Down
8 changes: 8 additions & 0 deletions src/libsemigroups_pybind11/froidure_pin.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
froidure_pin_current_normal_forms as _froidure_pin_current_normal_forms,
froidure_pin_current_position as _froidure_pin_current_position,
froidure_pin_current_rules as _froidure_pin_current_rules,
froidure_pin_dot_current_left_cayley_graph as _froidure_pin_dot_current_left_cayley_graph,
froidure_pin_dot_current_right_cayley_graph as _froidure_pin_dot_current_right_cayley_graph,
froidure_pin_dot_left_cayley_graph as _froidure_pin_dot_left_cayley_graph,
froidure_pin_dot_right_cayley_graph as _froidure_pin_dot_right_cayley_graph,
froidure_pin_equal_to as _froidure_pin_equal_to,
froidure_pin_factorisation as _froidure_pin_factorisation,
froidure_pin_minimal_factorisation as _froidure_pin_minimal_factorisation,
Expand Down Expand Up @@ -261,6 +265,10 @@ def sorted_elements( # pylint: disable=missing-function-docstring
# TODO(1) be good to get the notes about enumeration being triggered or not, in
# this doc

dot_current_left_cayley_graph = _wrap_cxx_free_fn(_froidure_pin_dot_current_left_cayley_graph)
dot_current_right_cayley_graph = _wrap_cxx_free_fn(_froidure_pin_dot_current_right_cayley_graph)
dot_left_cayley_graph = _wrap_cxx_free_fn(_froidure_pin_dot_left_cayley_graph)
dot_right_cayley_graph = _wrap_cxx_free_fn(_froidure_pin_dot_right_cayley_graph)
current_minimal_factorisation = _wrap_cxx_free_fn(_froidure_pin_current_minimal_factorisation)
current_normal_forms = _wrap_cxx_free_fn(_froidure_pin_current_normal_forms)
current_position = _wrap_cxx_free_fn(_froidure_pin_current_position)
Expand Down
Loading
Loading