10 #include <unordered_set> 20 using edgeType = std::unordered_set<size_t>;
21 using graphColorsType = std::pair<std::vector<unsigned short>,
unsigned short>;
23 enum class ColoringMethod
30 virtual ~
Graph() =
default;
35 void addEdge(
const size_t v,
const size_t w);
40 void getEdges(
const size_t v, edgeType& edges)
const;
61 graphColorsType
doColoring(ColoringMethod method = ColoringMethod::WelshPowell,
62 bool print =
false)
const;
78 ColoringMethod m_ColoringMethod = ColoringMethod::WelshPowell;
void print() const
print adjacency list representation of graph
void getEdges(const size_t v, edgeType &edges) const
Get edges surrounding a node.
graphColorsType doColoringWelshPowell(bool print=false) const
Colorize using Welsh-Powell algorithm and print the assignment of colors.
void setDefaultColoringMethod(ColoringMethod method)
Set the default colorizing method.
class to represent a graph object
graphColorsType doColoring(ColoringMethod method=ColoringMethod::WelshPowell, bool print=false) const
Colorize using the given method and prints the assignment of colors.
void addEdge(const size_t v, const size_t w)
Add edge to the graph.
graphColorsType doColoringGreedy(bool print=false) const
Colorize using greedy algorithm and print the assignment of colors.
std::vector< edgeType > m_adjList
A array of std::vectors to represent adjacency list.
size_t size() const
Get size of the graph.