Regina 7.3 Calculation Engine
|
Represents an undirected 4-valent planar graph with a specific planar embedding. More...
#include <link/modellinkgraph.h>
Public Member Functions | |
ModelLinkGraph () | |
Constructs an empty graph. More... | |
ModelLinkGraph (const Link &link) | |
Constructs the graph that models the given link. More... | |
ModelLinkGraph (const ModelLinkGraph ©) | |
Constructs a new copy of the given graph. More... | |
ModelLinkGraph (ModelLinkGraph &&src) noexcept | |
Moves the given graph into this new graph. More... | |
~ModelLinkGraph () | |
Destroys this graph. More... | |
size_t | size () const |
Returns the number of nodes in this graph. More... | |
ModelLinkGraphNode * | node (size_t index) const |
Returns the node at the given index within this graph. More... | |
auto | nodes () const |
Returns an object that allows iteration through and random access to all nodes in this graph. More... | |
ModelLinkGraph & | operator= (const ModelLinkGraph &src) |
Sets this to be a (deep) copy of the given graph. More... | |
ModelLinkGraph & | operator= (ModelLinkGraph &&src) noexcept |
Moves the contents of the given graph into this graph. More... | |
void | swap (ModelLinkGraph &other) noexcept |
Swaps the contents of this and the given graph. More... | |
bool | operator== (const ModelLinkGraph &other) const |
Determines if this graph is combinatorially identical to the given graph. More... | |
bool | operator!= (const ModelLinkGraph &other) const |
Determines if this graph is not combinatorially identical to the given graph. More... | |
void | reflect () |
Converts this graph into its reflection. More... | |
const ModelLinkGraphCells & | cells () const |
Returns details of the cellular decomposition of the sphere that is induced by this graph. More... | |
std::pair< ModelLinkGraphArc, ModelLinkGraphArc > | findFlype (const ModelLinkGraphArc &from) const |
Identifies the smallest flype that can be performed on this graph from the given starting location. More... | |
ModelLinkGraph | flype (const ModelLinkGraphArc &from, const ModelLinkGraphArc &left, const ModelLinkGraphArc &right) const |
Performs a flype on this graph at the given location. More... | |
ModelLinkGraph | flype (const ModelLinkGraphArc &from) const |
Performs the smallest possible flype on this graph from the given starting location. More... | |
template<typename Action , typename... Args> | |
void | generateMinimalLinks (Action &&action, Args &&... args) const |
Exhaustively generates potentially-minimal knot diagrams that are modelled by this graph. More... | |
std::string | plantri () const |
Outputs this graph in a variant of the ASCII text format used by plantri. More... | |
std::string | canonicalPlantri (bool useReflection=true, bool tight=false) const |
Outputs a text representation of this graph in a variant of the plantri ASCII format, using a canonical relabelling of nodes and arcs, and with optional compression. More... | |
void | writeTextShort (std::ostream &out) const |
Writes a short text representation of this graph to the given output stream. More... | |
void | writeTextLong (std::ostream &out) const |
Writes a detailed text representation of this graph to the given output stream. More... | |
std::string | str () const |
Returns a short text representation of this object. More... | |
std::string | utf8 () const |
Returns a short text representation of this object using unicode characters. More... | |
std::string | detail () const |
Returns a detailed text representation of this object. More... | |
Static Public Member Functions | |
static ModelLinkGraph | fromPlantri (const std::string &plantri) |
Builds a graph from a line of plantri output, using Regina's variant of the plantri ASCII format. More... | |
Represents an undirected 4-valent planar graph with a specific planar embedding.
This can be used as the model graph for a knot or link diagram, where each node of the graph becomes a crossing.
Current this class does not support circular graph components (which, in a link diagram, would correspond to zero-crossing unknot components of the link).
This class is primarily designed for enumerating knots and links. If you wish to study the underlying graph of an existing link, you do not need to create a ModelLinkGraph - instead the Link class already gives you direct access to the graph structure. In particular, if you include link/graph.h, you can use a Link directly as a directed graph type with the Boost Graph Library.
This class implements C++ move semantics and adheres to the C++ Swappable requirement. It is designed to avoid deep copies wherever possible, even when passing or returning objects by value.
|
inline |
Constructs an empty graph.
regina::ModelLinkGraph::ModelLinkGraph | ( | const Link & | link | ) |
Constructs the graph that models the given link.
Any zero-component unknot components of the link will be ignored.
The nodes of this graph will be numbered in the same way as the crossings of link. For each node, arc 0 will represent the outgoing lower strand of the corresponding crossing.
Using this constructor is identical to calling Link::graph().
link | the link that this new graph will model. |
regina::ModelLinkGraph::ModelLinkGraph | ( | const ModelLinkGraph & | copy | ) |
Constructs a new copy of the given graph.
copy | the graph to copy. |
|
inlinenoexcept |
Moves the given graph into this new graph.
This is a fast (constant time) operation.
All nodes and cells that belong to src will be moved into this graph, and so any ModelLinkGraphNode or ModelLinkGraphCells pointers or references will remain valid.
The graph that is passed (src) will no longer be usable.
src | the graph to move. |
|
inline |
Destroys this graph.
The ModelLinkGraphNode objects contained in this graph will also be destroyed.
std::string regina::ModelLinkGraph::canonicalPlantri | ( | bool | useReflection = true , |
bool | tight = false |
||
) | const |
Outputs a text representation of this graph in a variant of the plantri ASCII format, using a canonical relabelling of nodes and arcs, and with optional compression.
This routine is similar to plantri(), but with two significant differences:
true
then we allow for reflection also.true
, then this routine uses an abbreviated output format. The resulting compression is only trivial (it reduces the length by roughly 40%), but the resulting string is still human-parseable (though with a little more effort required). This compression will simply remove the commas, and for each node it will suppress the destination of the first arc (since this can be deduced from the canonical labelling).Regardless of whether tight is true
or false
, the resulting string can be parsed by fromPlantri() to reconstruct the original graph. Note however that, due to the canonical labelling, the resulting graph might be a relabelling of the original (and might even be a reflection of the original, if useReflection was passed as true
).
See plantri() for further details on the ASCII format itself, including the ways in which Regina's implementation of this format differs from plantri's for graphs with more than 26 nodes.
The running time for this routine is quadratic in the size of the graph.
FailedPrecondition | This graph has more than 52 nodes. |
useReflection | true if a graph and its reflection should be considered the same (i.e., produce the same canonical output), or false if they should be considered different. Of course, if a graph is symmetric under reflection then the graph and its reflection will produce the same canonical output regardless of this parameter. |
tight | false if the usual plantri ASCII format should be used (as described by plantri() and fromPlantri()), or true if the abbreviated format should be used as described above. |
|
inline |
Returns details of the cellular decomposition of the sphere that is induced by this graph.
This cellular decomposition will only be computed on demand. This means that the first call to this function will take linear time (as the decomposition is computed), but subsequent calls will be constant time (since the decomposition is cached).
|
inherited |
Returns a detailed text representation of this object.
This text may span many lines, and should provide the user with all the information they could want. It should be human-readable, should not contain extremely long lines (which cause problems for users reading the output in a terminal), and should end with a final newline. There are no restrictions on the underlying character set.
std::pair< ModelLinkGraphArc, ModelLinkGraphArc > regina::ModelLinkGraph::findFlype | ( | const ModelLinkGraphArc & | from | ) | const |
Identifies the smallest flype that can be performed on this graph from the given starting location.
Here we use the same notation as in the three-argument flype() function, where you perform a flype by passing three arcs from, left and right. Read the flype() documentation now if you have not done so already; this includes a full description of the flype operation as well as diagrams with the arcs from, left and right clearly marked.
The given arc from identifies the node to the left of the flype disc. The aim of this routine is to identify two suitable arcs left and right that exit through the right of the flype disc. Together, these three arcs uniquely identify the entire flype disc, and therefore prescribe the operation precisely.
Here, by "suitable arcs", we mean a pair of arcs (left, right) for which the three arcs (from, left, right) together satisfy the preconditions for the flype() routine.
There are several possible outcomes:
It should be noted that choosing only the smallest flype is not a serious restriction: assuming the graph does not model a composition of non-trivial knot diagrams, any suitable flype can be expressed as a composition of minimal flypes in this sense.
from | the arc that indicates where the flype disc should begin. This is the arc labelled from in the diagrams for the three-argument flype() function: it is the lower of the two arcs that enter the flype disc from the node X to the left of the disc. This should be presented as an arc of the node X. |
|
inline |
Performs the smallest possible flype on this graph from the given starting location.
This is a convenience routine that simply calls findFlype() to identify the smallest possible flype from the given starting location, and then calls the three-argument flype() to actually perform it. If there is no possible flype from the given starting location then this routine throws an exception.
See the documentation for the three-argument flype() for further details on the flype operation, and see findFlype() for a discussion on what is meant by "smallest possible".
InvalidArgument | There is no suitable flype on this graph from the given starting location (that is, findFlype() returns a pair of null arcs). |
from | the arc that indicates where the flype disc should begin. This is the arc labelled from in the diagrams for the three-argument flype() function: it is the lower of the two arcs that enter the flype disc from the node X to the left of the disc. This should be presented as an arc of the node X. |
ModelLinkGraph regina::ModelLinkGraph::flype | ( | const ModelLinkGraphArc & | from, |
const ModelLinkGraphArc & | left, | ||
const ModelLinkGraphArc & | right | ||
) | const |
Performs a flype on this graph at the given location.
A flype is an operation on a disc in the plane. The boundary of the disc must cut through four arcs of the graph (and otherwise must not meet the graph at all), as indicated in the diagram below. Moreover, the two arcs that exit the disc on the left must meet at a common node just outside the disc. (The punctuation symbols drawn inside the disc are just to help illustrate how the transformation works.)
______ ______ / \ / \ __ __| ## ** |_______ _______| :: <> |__ __ \ / | | | | \ / X | Disc | ==> | | X __/ \__| |_______ _______| |__/ \__ | :: <> | | ## ** | \______/ \______/
The operation involves:
The equivalent operation on a knot diagram involves twisting the entire region inside the disc about a horizontal axis, in a way that undoes the crossing on the left but introduces a new crossing on the right instead.
You will need to pass arguments to indicate where the flype should take place. For this, we will label some of the features of the initial diagram (before the move takes place): see the diagram below. Here the labels from, left and right all refer to arcs. The labels A, B, C and D all refer to dual 2-cells in the plane; these are not passed as arguments, but they do appear in the list of preconditions for this routine.
______ Cell A / \ __ __________| |_________ left \ / | | X Cell B | | Cell D __/ \__________| |_________ right from | | Cell C \______/
The arc from must be given as an arc of the node outside the disc (i.e., the node to the left of cell B). The arcs left and right must be given as arcs of their respective nodes inside the disc.
left.traverse().node()
nor right.traverse().node()
is equal to from.node()
. (If this fails, then either the flype simply reflects the entire graph, or else the graph models a composition of two non-trivial knot diagrams.)InvalidArgument | One or more of the preconditions above fails to hold. Be warned that the connectivity precondition will not be checked - this is the user's responsibility - but all other preconditions will be checked, and an exception will be thrown if any of them fails. |
from | the first arc that indicates where the flype should take place, as labelled on the diagram above. This should be presented as an arc of the node outside the disc, to the left. |
left | the second arc that indicates where the flype should take place, as labelled on the diagram above. This should be presented as an arc of the node that it meets inside the disc. |
right | the third arc that indicates where the flype should take place, as labelled on the diagram above. This should be presented as an arc of the node that it meets inside the disc. |
|
static |
Builds a graph from a line of plantri output, using Regina's variant of the plantri ASCII format.
The software plantri, by Gunnar Brinkmann and Brendan McKay, can be used to enumerate 4-valent planar graphs (amongst many other things). This routine converts a piece of output from plantri, or the encoding of a graph using Regina's own plantri() or canonicalPlantri() functions, into a ModelLinkGraph object that Regina can work with directly.
If you are converting output from plantri, this output must be in ASCII format, and must be the dual graph of a simple quadrangulation of the sphere. The corresponding flags that must be passed to plantri to obtain such output are -adq
(although you will may wish to pass additional flags to expand or restrict the classes of graphs that plantri builds).
When run with these flags, plantri produces output in the following form:
6 bbcd,adca,abee,affb,cffc,deed 6 bcdd,aeec,abfd,acfa,bffb,ceed 6 bcde,affc,abfd,acee,addf,becb
Each line consists of an integer (the number of nodes in the graph), followed by a comma-separated sequence of alphabetical strings that encode the edges leaving each node.
This function only takes the comma-separated sequence of alphabetical strings. So, for example, to construct the graph corresponding to the second line of output above, you could call:
Regina uses its own variant of plantri's output format, which is identical for smaller graphs but which differs from plantri's own output format for larger graphs. In particular:
A
,...,Z
. For these larger graphs, Regina can only recognise Regina's own plantri() and canonicalPlantri() output, not plantri's punctuation-based encodings.Even for graphs with at most 26 nodes, the given string does not need to be come from the program plantri itself. Whereas plantri always outputs graphs with a particular canonical labelling, this function can accept an arbitrary ordering of nodes and arcs - in particular, it can accept the string g.plantri()
for any graph g that meets the preconditions below. Nevertheless, the graph must still meet these preconditions, since otherwise the plantri format might not be enough to uniquely reconstruct the graph and its planar embedding.
This routine can also interpret the "tight" format that is optionally produced by the member function canonicalPlantri() (even though such output would certainly not be produced by the program plantri).
InvalidArgument | The input was not a valid representation of a graph using the plantri output format. As noted above, the checks performed here are not exhaustive. |
plantri | a string containing the comma-separated sequence of alphabetical strings in plantri format, as described above. |
void regina::ModelLinkGraph::generateMinimalLinks | ( | Action && | action, |
Args &&... | args | ||
) | const |
Exhaustively generates potentially-minimal knot diagrams that are modelled by this graph.
Here potentially-minimal means there are no "obvious" simplification moves (such as a simplifying type II Reidemeister move, for example). The list of "obvious" moves considered here is subject to change in future versions of Regina.
By exhaustive, we mean:
In other words, this routine will generate all minimal knot diagrams modelled by this graph, but there is no promise that all of the diagrams generated are minimal.
Labelled diagrams are only generated once up to reflection and/or reversal, in that this routine will fix the orientation of the knot (always following arc 0 away from node 0 of the graph) and the sign of the crossing at node 0 (always positive).
In each knot diagram that is generated, crossing k will always correspond to node k of this graph.
For each knot diagram that is generated, this routine will call action (which must be a function or some other callable object).
void
.FailedPrecondition | This graph models links with more than one component. |
action | a function (or other callable object) to call for each knot diagram that is generated. |
args | any additional arguments that should be passed to action, following the initial knot diagram argument. |
|
inline |
Returns the node at the given index within this graph.
For a graph with n nodes, the nodes are numbered from 0 to n-1 inclusive.
index | the index of the requested node. This must be between 0 and size()-1 inclusive. |
|
inline |
Returns an object that allows iteration through and random access to all nodes in this graph.
The object that is returned is lightweight, and can be happily copied by value. The C++ type of the object is subject to change, so C++ users should use auto
(just like this declaration does).
The returned object is guaranteed to be an instance of ListView, which means it offers basic container-like functions and supports range-based for
loops. Note that the elements of the list will be pointers, so your code might look like:
The object that is returned will remain up-to-date and valid for as long as the graph exists: even if nodes are added and/or removed, it will always reflect the nodes that are currently in the graph. Nevertheless, it is recommended to treat this object as temporary only, and to call nodes() again each time you need it.
|
inline |
Determines if this graph is not combinatorially identical to the given graph.
Here "identical" means that both graphs have the same number of nodes, and in both graphs the same pairs of outgoing arcs of numbered nodes are connected by edges.
other | the graph to compare with this. |
true
if and only if the two graphs are not combinatorially identical. ModelLinkGraph & regina::ModelLinkGraph::operator= | ( | const ModelLinkGraph & | src | ) |
Sets this to be a (deep) copy of the given graph.
src | the graph to copy. |
|
inlinenoexcept |
Moves the contents of the given graph into this graph.
This is a fast (constant time) operation.
All nodes and cells that belong to src will be moved into this graph, and so any ModelLinkGraphNode or ModelLinkGraphCells pointers or references will remain valid.
The graph that is passed (src) will no longer be usable.
src | the graph to move. |
bool regina::ModelLinkGraph::operator== | ( | const ModelLinkGraph & | other | ) | const |
Determines if this graph is combinatorially identical to the given graph.
Here "identical" means that both graphs have the same number of nodes, and in both graphs the same pairs of outgoing arcs of numbered nodes are connected by edges.
other | the graph to compare with this. |
true
if and only if the two graphs are combinatorially identical. std::string regina::ModelLinkGraph::plantri | ( | ) | const |
Outputs this graph in a variant of the ASCII text format used by plantri.
The software plantri, by Gunnar Brinkmann and Brendan McKay, can be used to enumerate 4-valent planar graphs (amongst many other things). This routine outputs this graph in a format that mimics plantri's own dual ASCII format (i.e., the format that plantri outputs when run with the flags -adq
).
Specifically, the output will be a comma-separated sequence of alphabetical strings. The ith such string will consist of four letters, encoding the endpoints of the four edges in clockwise order that leave node i. The lower-case letters a
,b
,...,z
represent nodes 0,1,...,25 respectively, and the upper-case letters A
,B
,...,Z
represent nodes 26,27,...,51 respectively. An example of such a string is:
bcdd,aeec,abfd,acfa,bffb,ceed
For graphs with at most 26 nodes, this is identical to plantri's own dual ASCII format. For larger graphs, this format differs: plantri uses punctuation to represent higher-index nodes, whereas Regina uses upper-case letters.
This routine is an inverse to fromPlantri(): for any graph g that satisfies the preconditions below, fromPlantri(g.plantri())
is identical to g. Likewise, for any string s that satisfies the preconditions for fromPlantri(), calling fromPlantri(s).plantri()
will recover the original string s.
It is important to note the preconditions below: in particular, that this graph must be dual to a simple quadrangulation of the sphere. This is because the planar embeddings for more general graphs (i.e., the duals of non-simple quadrangulations) cannot always be uniquely reconstructed from their plantri output.
FailedPrecondition | This graph has more than 52 nodes. |
void regina::ModelLinkGraph::reflect | ( | ) |
Converts this graph into its reflection.
This routine simply reverses (and also cycles) the order of outgoing arcs around every node.
|
inline |
Returns the number of nodes in this graph.
|
inherited |
Returns a short text representation of this object.
This text should be human-readable, should use plain ASCII characters where possible, and should not contain any newlines.
Within these limits, this short text ouptut should be as information-rich as possible, since in most cases this forms the basis for the Python __str__()
and __repr__()
functions.
__str__()
will use precisely this function, and for most classes the Python __repr__()
function will incorporate this into its output.
|
inlinenoexcept |
Swaps the contents of this and the given graph.
All nodes that belong to this graph will be moved to other, and all nodes that belong to other will be moved to this graph.
In particular, any ModelLinkGraphNode pointers or references and any ModelLinkGraphArc objects will remain valid.
This routine will behave correctly if other is in fact this graph.
other | the graph whose contents should be swapped with this. |
|
inherited |
Returns a short text representation of this object using unicode characters.
Like str(), this text should be human-readable, should not contain any newlines, and (within these constraints) should be as information-rich as is reasonable.
Unlike str(), this function may use unicode characters to make the output more pleasant to read. The string that is returned will be encoded in UTF-8.
void regina::ModelLinkGraph::writeTextLong | ( | std::ostream & | out | ) | const |
Writes a detailed text representation of this graph to the given output stream.
out | the output stream to which to write. |
void regina::ModelLinkGraph::writeTextShort | ( | std::ostream & | out | ) | const |
Writes a short text representation of this graph to the given output stream.
out | the output stream to which to write. |