5.2. canonicalization.hpp¶
Full path: graph_canon/canonicalization.hpp
-
template<typename
SizeTypeT
, boolParallelEdgesV
, boolLoopsV
, typenameGraphT
, typenameIndexMapT
, typenameEdgeHandlerT
>
classconfig
¶ A helper-class for holding type aliases.
-
static constexpr bool
ParallelEdges
= ParallelEdgesV¶ Indicator for whether the graph can have parallel edges.
-
using
EdgeHandler
= EdgeHandlerT¶ The type of
EdgeHandler
used.
-
static constexpr bool
-
template<typename
ConfigT
, typenameVisitorT
>
classcanon_state
¶ A class template representing he state of a canonicalization run. A reference to an object of this class will be passed to almost all functions in plugins. Note that the user is not supposed to instantiate an object of this class manually.
-
type
SizeType
¶ The integer type used as element type in various arrays.
-
type
Graph
¶ The type of the input graph.
-
type
IndexMap
¶ The
ReadablePropertyMap
given to map vertices to indices.
-
type
EHandler
¶ The
EdgeHandler
type used.
-
static constexpr bool
ParallelEdges
¶ Configuration value for whether the given graph may have parallel edges or not.
-
static constexpr bool
Loops
¶ Configuration value for whether the given graph may have loop edges or not.
-
type
Partition
¶ The type of
OrderedPartition
used in the algorithm.
-
type
TreeNode
¶ The type used for instantiating tree nodes.
-
type
OwnerPtr
¶ A smart-pointer type that keeps a tree node alive (e.g., by reference counting).
-
type
InstanceData
¶ Instance data defined, e.g., by visitors, is all stored in an object of this type
-
void
report_leaf
(OwnerPtr node)¶ Submit a tree node as a valid leaf of the search tree.
Requires that the ordered partition represented by
node
is discrete, and thatreport_leaf
has not been called before with this node.Several
Visitor
methods may be called from this function:Visitor::tree_leaf
, always called.Visitor::canon_new_best
, if this node will be the best candidate leaf afterwards.Visitor::automorphism_leaf
, if this node represents a canonical representation, equal to the current best candidate.Visitor::canon_worse
, if this nodes represents a worse representation than the current best candidate.
-
void
prune_canon_leaf
()¶ Prune the current best candidate. Requires that at least one leaf will be added with
repoort_leaf
later.
-
TreeNode *
get_canon_leaf
() const¶ - Returns
a pointer to the tree node representing the current best candidate.
-
InstanceData
data
¶ The aggregated data structure holding all instance data. Use
get(my_tag(), data)
to access your data, tagged with some tagmy_tag
.
-
EHandler &
edge_handler
¶ A reference to the
EdgeHandler
used for this run.
-
type
-
template<typename
SizeType
, typenameEdgeHandlerCreatorT
, boolParallelEdges
, boolLoops
>
classcanonicalizer
¶ A reusable function object for canonicalizing graphs.
Requires
SizeType
to be an integer type andEdgeHandlerCreatorT
to be anEdgeHandlerCreator
.-
using
EdgeHandler
= typename EdgeHandlerCreatorT::template type<SizeType>¶
-
canonicalizer
(EdgeHandlerCreatorT edge_handler_creator)¶
-
template<typename
Graph
, typenameIndexMap
, typenameVertexLess
, typenameVis
>
autooperator()
(const Graph &g, IndexMap idx, VertexLess vertex_less, Vis visitor)¶ Compute a permutation that permutes the indices of the vertices of
g
into their canonical indices.Requires:
Graph
must be aVertexListGraph
, anEdgeListGraph
, and aBidirectionalGraph
.IndexMap
must be aReadablePropertyMap
that maps the vertices ofg
into contiguous indices starting from 0.VertexLess
must be a less-than predicate on the vertices ofg
that induces a strict weak ordering. The resulting canonical vertex order respects the ordering induced byvertex_less
.Vis
must be aVisitor
type. Note that aninvariant_coordinator
is automatically prepended to the given visitor.
Note
Currently the expression
vertex(i, g)
for a vertex indexi
is also required to be valid, and returning the corresponding vertex descriptor. It must be the inverse of the index mapidx
. This requirement will be lifted in a future version.- Returns
A
std::pair<std::vector<SizeType>, Data>
wherefirst
is the permutation, andsecond
is the auxiliary visitor data of an unspecified typeData
. See each visitor for what data they may return and what it is tagged with. Useget(the_tag(), res.second)
to access the data tagged withthe_tag
from the return valueres
.
-
using
-
template<typename
SizeType
, boolParallelEdges
, boolLoops
, typenameGraph
, typenameIndexMap
, typenameVertexLess
, typenameEdgeHandlerCreatorT
, typenameVisitor
>
autocanonicalize
(const Graph &graph, IndexMap idx, VertexLess vertex_less, EdgeHandlerCreatorT edge_handler_creator, Visitor visitor)¶ A shorhand function for canonicalization. The
SizeType
,ParallelEdges
, andLoops
must be specified explicitly while remaining template parameters can be deduced.See
canonicalizer::
.operator()