25 #ifndef DIALECT_NEARALIGN_H 26 #define DIALECT_NEARALIGN_H 31 #include "libdialect/constraints.h" 32 #include "libdialect/opts.h" 33 #include "libdialect/commontypes.h" 37 enum class AlignmentFlag {
46 inline AlignmentFlag
operator&(AlignmentFlag a, AlignmentFlag b)
47 {
return static_cast<AlignmentFlag
>(
static_cast<int>(a) & static_cast<int>(b));}
49 inline AlignmentFlag& operator|= (AlignmentFlag& a, AlignmentFlag b) {
return (AlignmentFlag&)((
int&)a |= (
int)b); }
51 struct AlignmentTable {
54 AlignmentTable(Graph &graph,
const Nodes &ignore);
57 AlignmentTable(Graph &graph,
const NodesById &ignore);
64 bool areAligned(id_type uid, id_type vid, AlignmentFlag flag);
70 void addAlignment(id_type uid, id_type vid, AlignmentFlag flag);
75 void addAlignments(
const NodesById &nodes,
const SepMatrix &matrix);
81 std::vector<id_type> getAlignedIds(id_type uid, AlignmentFlag flag);
90 void noteInfeasibility(id_type uid, id_type vid, AlignmentFlag flag);
97 bool isMarkedInfeasible(id_type uid, id_type vid, AlignmentFlag flag);
100 SparseIdMatrix2d<AlignmentFlag>::type state;
108 struct PotentialAlignment {
111 PotentialAlignment(Node_SP u, Node_SP v, AlignmentFlag flag)
121 void addToTable(AlignmentTable &table) { table.addAlignment(u->id(), v->id(), flag); }
124 void noteInfeasibility(AlignmentTable &table) { table.noteInfeasibility(u->id(), v->id(), flag); }
127 SepCo_SP writeSepCo(
void);
130 void addToGraph(Graph &G);
137 bool removed =
false;
138 PotentialAlignment *prev =
nullptr;
139 PotentialAlignment *next =
nullptr;
142 typedef std::vector<PotentialAlignment*> PotentialAlignments;
154 size_t doNearAlignments(
dialect::Graph &graph, dialect::AlignmentTable &atab, dialect::NodesById &ignore,
const dialect::HolaOpts &opts,
bool reattempt=
false);
160 #endif // DIALECT_NEARALIGN_H The Graph class represents graphs consisting of nodes and edges.
Definition: graphs.h:180
double manhattan(Node_SP u, Node_SP v)
Report the "Manhattan distance" between two nodes.
Definition: nearalign.cpp:126
libdialect: A library for computing human-like orthogonal network (DiAlEcT) layouts.
Definition: cola.h:44
size_t doNearAlignments(dialect::Graph &graph, dialect::AlignmentTable &atab, dialect::NodesById &ignore, const dialect::HolaOpts &opts, bool reattempt=false)
Look for nodes that are nearly aligned, and try to align them.
Definition: nearalign.cpp:156
AlignmentFlag operator &(AlignmentFlag a, AlignmentFlag b)
Thanks to https://stackoverflow.com/a/1448478.
Definition: nearalign.h:46