Limbo
|
#include <GraphSimplification.h>
Public Types | |
enum | vertex_status_type { GOOD, HIDDEN, MERGED } |
status of vertex. More... | |
enum | strategy_type { NONE = 0, HIDE_SMALL_DEGREE = 1, MERGE_SUBK4 = 2, BICONNECTED_COMPONENT = 4 } |
simplification strategies available. These strategies are order-sensitive. It is recommended to call simplify(), e.g. simplify(HIDE_SMALL_DEGREE | BICONNECTED_COMPONENT) More... | |
typedef GraphType | graph_type |
typedef boost::graph_traits < graph_type > ::vertex_descriptor | graph_vertex_type |
typedef boost::graph_traits < graph_type > ::edge_descriptor | graph_edge_type |
typedef boost::graph_traits < graph_type > ::vertex_iterator | vertex_iterator |
typedef boost::graph_traits < graph_type > ::adjacency_iterator | adjacency_iterator |
typedef boost::graph_traits < graph_type >::edge_iterator | edge_iterator |
Public Member Functions | |
GraphSimplification (graph_type const &g, uint32_t color_num) | |
GraphSimplification (GraphSimplification const &rhs) | |
template<typename Iterator > | |
void | precolor (Iterator first, Iterator last) |
std::vector < vertex_status_type > const & | status () const |
std::vector< graph_vertex_type > const & | parents () const |
std::vector< std::vector < graph_vertex_type > > const & | children () const |
std::stack< graph_vertex_type > const & | hidden_vertices () const |
std::pair< graph_type, std::map< graph_vertex_type, graph_vertex_type > > | simplified_graph () const |
bool | simplified_graph_component (uint32_t comp_id, graph_type &sg, std::vector< graph_vertex_type > &vSimpl2Orig) const |
uint32_t | num_component () const |
void | max_merge_level (int32_t l) |
void | simplify (uint32_t level) |
void | recover (std::vector< int8_t > &vColorFlat, std::vector< std::vector< int8_t > > &mColor, std::vector< std::vector< graph_vertex_type > > const &mSimpl2Orig) const |
void | merge_subK4 () |
void | hide_small_degree () |
hide vertices whose degree is no larger than number of colors - 1 More... | |
void | biconnected_component () |
find all articulation points and biconnected components | |
void | recover_merge_subK4 (std::vector< int8_t > &vColor) const |
void | recover_biconnected_component (std::vector< std::vector< int8_t > > &mColor, std::vector< std::vector< graph_vertex_type > > const &mSimpl2Orig) const |
recover color for biconnected components More... | |
void | recover_hide_small_degree (std::vector< int8_t > &vColor) |
void | write_graph_dot (std::string const &filename) const |
void | write_simplified_graph_dot (std::string const &filename) const |
Protected Member Functions | |
void | biconnected_component_recursion (graph_vertex_type v, std::deque< bool > &vVisited, std::vector< uint32_t > &vDisc, std::vector< uint32_t > &vLow, std::vector< graph_vertex_type > &vParent, uint32_t &visit_time, std::stack< std::pair< graph_vertex_type, graph_vertex_type > > &vEdge, std::list< std::pair< graph_vertex_type, std::set< graph_vertex_type > > > &mCompVertex) const |
void | connected_component () |
compute connected components | |
graph_vertex_type | parent (graph_vertex_type v) const |
graph_vertex_type | parent (uint32_t v, std::vector< uint32_t > const &vParent) const |
bool | connected_conflict (graph_vertex_type v1, graph_vertex_type v2) const |
bool | connected_stitch (graph_vertex_type v1, graph_vertex_type v2) const |
std::pair< graph_edge_type, bool > | connected_edge (graph_vertex_type v1, graph_vertex_type v2) const |
bool | merged (graph_vertex_type v1) const |
bool | good (graph_vertex_type v1) const |
bool | hidden (graph_vertex_type v1) const |
bool | precolored (graph_vertex_type v1) const |
bool | articulation_point (graph_vertex_type v) const |
bool | has_precolored () const |
bool | check_max_merge_level (uint32_t l) const |
Protected Attributes | |
graph_type const & | m_graph |
original graph | |
uint32_t | m_color_num |
number of colors | |
uint32_t | m_level |
simplification level | |
uint32_t | m_max_merge_level |
in MERGE_SUBK4, any merge that results in the children number of a vertex larger than m_max_merge_level is disallowed | |
std::vector< vertex_status_type > | m_vStatus |
status of each vertex | |
std::vector< graph_vertex_type > | m_vParent |
parent vertex of current vertex | |
std::vector< std::vector < graph_vertex_type > > | m_vChildren |
children verices of current vertex, a vertex is the child of itself if it is not merged | |
std::stack< graph_vertex_type > | m_vHiddenVertex |
a std::stack that keeps a reverse order of vertices hidden, useful for color recovery | |
std::vector< std::vector < graph_vertex_type > > | m_mCompVertex |
group vertices by components | |
std::map< graph_vertex_type, std::set< uint32_t > > | m_mArtiPoint |
map of (vertex of articulation point, set of components split by the vertex) | |
std::vector< int8_t > | m_vPrecolor |
precolor information, if uncolored, std::set to -1 | |
Various graph simplification techniques for graph coloring.
GraphType | graph type |
Definition at line 51 of file GraphSimplification.h.
enum limbo::algorithms::coloring::GraphSimplification::strategy_type |
simplification strategies available. These strategies are order-sensitive. It is recommended to call simplify(), e.g. simplify(HIDE_SMALL_DEGREE | BICONNECTED_COMPONENT)
Definition at line 73 of file GraphSimplification.h.
enum limbo::algorithms::coloring::GraphSimplification::vertex_status_type |
status of vertex.
Enumerator | |
---|---|
GOOD |
still in graph |
HIDDEN |
vertex is hidden by simplification |
MERGED |
vertex is merged to other vertex |
Definition at line 64 of file GraphSimplification.h.
|
inline |
constructor
g | graph |
color_num | number of colors |
Definition at line 82 of file GraphSimplification.h.
limbo::algorithms::coloring::GraphSimplification< GraphType >::GraphSimplification | ( | GraphSimplification< GraphType > const & | rhs | ) |
copy constructor is not allowed
rhs | a GraphSimplification object |
|
inlineprotected |
v | vertex |
Definition at line 320 of file GraphSimplification.h.
|
protected |
recursive implementation of computing biconnected components
v | current vertex |
vVisited | an array records whether a vertex has been visited |
vDisc | discovery time of vertices |
vLow | low values of vertices |
vParent | parents of vertices |
visit_time | records current visiting time |
vEdge | a stack of edges for DFS |
mCompVertex | vertices arranged by independent components |
Definition at line 832 of file GraphSimplification.h.
|
inlineprotected |
l | merge level |
Definition at line 336 of file GraphSimplification.h.
|
inline |
Definition at line 129 of file GraphSimplification.h.
|
inlineprotected |
v1 | vertex |
v2 | vertex |
Definition at line 238 of file GraphSimplification.h.
|
inlineprotected |
v1 | vertex |
v2 | vertex |
Definition at line 274 of file GraphSimplification.h.
|
inlineprotected |
v1 | vertex |
v2 | vertex |
Definition at line 256 of file GraphSimplification.h.
|
inlineprotected |
v1 | vertex |
Definition at line 302 of file GraphSimplification.h.
|
inlineprotected |
Definition at line 325 of file GraphSimplification.h.
|
inlineprotected |
v1 | vertex |
Definition at line 308 of file GraphSimplification.h.
|
inline |
Definition at line 131 of file GraphSimplification.h.
void limbo::algorithms::coloring::GraphSimplification< GraphType >::hide_small_degree | ( | ) |
hide vertices whose degree is no larger than number of colors - 1
hide vertices whose degree is no larger than color_num-1
Definition at line 678 of file GraphSimplification.h.
|
inline |
void limbo::algorithms::coloring::GraphSimplification< GraphType >::merge_subK4 | ( | ) |
For a structure of K4 with one fewer edge, suppose we have 4 vertices 1, 2, 3, 4, edges 1–2, 1–3, 2–3, 2–4, 3–4. Vertex 4 is merged to 1. This strategy only works for 3-coloring. It cannot guarantee minimal conflicts, but it can be used in a native conflict checker.
for a structure of K4 with one fewer edge suppose we have 4 vertices 1, 2, 3, 4 1–2, 1–3, 2–3, 2–4, 3–4, vertex 4 is merged to 1 this strategy only works for 3-coloring it cannot guarantee minimal conflicts but it can be used in a native conflict checker
Definition at line 569 of file GraphSimplification.h.
|
inlineprotected |
v1 | vertex |
Definition at line 290 of file GraphSimplification.h.
|
inline |
Definition at line 142 of file GraphSimplification.h.
|
inlineprotected |
v | vertex |
Definition at line 216 of file GraphSimplification.h.
|
inlineprotected |
v | vertex |
vParent | parent array of vertices |
Definition at line 229 of file GraphSimplification.h.
|
inline |
Definition at line 127 of file GraphSimplification.h.
|
inline |
set precolored vertices
Iterator | iterator type |
first,last | begin and end of the precolored vertex array |
Definition at line 116 of file GraphSimplification.h.
|
inlineprotected |
v1 | vertex |
Definition at line 314 of file GraphSimplification.h.
void limbo::algorithms::coloring::GraphSimplification< GraphType >::recover | ( | std::vector< int8_t > & | vColorFlat, |
std::vector< std::vector< int8_t > > & | mColor, | ||
std::vector< std::vector< graph_vertex_type > > const & | mSimpl2Orig | ||
) | const |
API to recover coloring solutions from color assignment of simplified graph
vColorFlat | flatten coloring solutions for original graph |
mColor | coloring solutions arranged by components |
mSimpl2Orig | mapping from simplified graph components to original graph |
Definition at line 530 of file GraphSimplification.h.
void limbo::algorithms::coloring::GraphSimplification< GraphType >::recover_biconnected_component | ( | std::vector< std::vector< int8_t > > & | mColor, |
std::vector< std::vector< graph_vertex_type > > const & | mSimpl2Orig | ||
) | const |
recover color for biconnected components
recover color for biconnected components
mColor | coloring solutions arranged by components |
mSimpl2Orig | mapping from simplified graph components to original graph |
Definition at line 1054 of file GraphSimplification.h.
void limbo::algorithms::coloring::GraphSimplification< GraphType >::recover_hide_small_degree | ( | std::vector< int8_t > & | vColor | ) |
recover color for hidden vertices need to be called manually, no density balance considered this function is mutable because it pops out elements in m_vHiddenVertex
vColor | coloring solutions, it must be partially assigned colors except simplified vertices |
Definition at line 1163 of file GraphSimplification.h.
void limbo::algorithms::coloring::GraphSimplification< GraphType >::recover_merge_subK4 | ( | std::vector< int8_t > & | vColor | ) | const |
recover merged vertices
vColor | must be partially assigned colors except simplified vertices |
Definition at line 1033 of file GraphSimplification.h.
std::pair< typename GraphSimplification< GraphType >::graph_type, std::map< typename GraphSimplification< GraphType >::graph_vertex_type, typename GraphSimplification< GraphType >::graph_vertex_type > > limbo::algorithms::coloring::GraphSimplification< GraphType >::simplified_graph | ( | ) | const |
Definition at line 363 of file GraphSimplification.h.
bool limbo::algorithms::coloring::GraphSimplification< GraphType >::simplified_graph_component | ( | uint32_t | comp_id, |
graph_type & | sg, | ||
std::vector< graph_vertex_type > & | vSimpl2Orig | ||
) | const |
extract a component from simplified graph
comp_id | component id |
sg | component of simplified graph |
vSimpl2Orig | mapping from simplified graph to original graph |
Definition at line 422 of file GraphSimplification.h.
void limbo::algorithms::coloring::GraphSimplification< GraphType >::simplify | ( | uint32_t | level | ) |
API to run the simplification algorithm
level | simplification level, can be combination of items in limbo::algorithms::coloring::GraphSimplification::strategy_type |
Definition at line 497 of file GraphSimplification.h.
|
inline |
Definition at line 125 of file GraphSimplification.h.
void limbo::algorithms::coloring::GraphSimplification< GraphType >::write_graph_dot | ( | std::string const & | filename | ) | const |
write graph in graphviz format
filename | output file name |
Definition at line 1194 of file GraphSimplification.h.
void limbo::algorithms::coloring::GraphSimplification< GraphType >::write_simplified_graph_dot | ( | std::string const & | filename | ) | const |
write simplified graph in graphviz format
filename | output file name |
Definition at line 1256 of file GraphSimplification.h.