138 : m_set(set), m_indices(subsetSize), m_numElements(subsetSize) {
140 for (
Index i = 0; i < m_numElements; i++) {
151 for (
Index i = 0; i < m_numElements; i++) {
152 if (m_indices[i] > (m_set.
size() - m_numElements + i)) {
166 for (
Index i = 0; i < m_numElements; i++) {
179 for (
Index i = m_numElements - 1; i >= 0; i--) {
181 if (m_indices[i] <= (m_set.
size() + i - m_numElements)) {
182 for (
int j = i + 1; j < m_numElements; j++) {
183 m_indices[j] = m_indices[i] + j - i;
215 template<
class CONTAINER>
218 for (
node v : nodes) {
221 for (
node v : nodes) {
222 for (
adjEntry adj : v->adjEntries) {
223 if (nodeSet.
isMember(adj->twinNode()) && adj->twinNode() != v) {
250 template<
class LISTITERATOR>
255 for (LISTITERATOR its = nodes; its.valid(); its++) {
261 node twin = adj->twinNode();
262 if (!isInserted[twin]) {
264 isInserted[twin] =
true;
289 template<
class LISTITERATOR>
293 complementNeighbors.
clear();
297 for (LISTITERATOR its = nodes; its.valid(); its++) {
301 isComplement[v] =
false;
306 getNeighbors<LISTITERATOR>(graph, nodes, neighbors);
307 for (
node& v : neighbors) {
308 isComplement[v] =
false;
313 if (isComplement[v]) {
328 template<
class LISTITERATOR>
334 for (
auto& iterator : iterators) {
335 for (LISTITERATOR its = iterator; its.valid(); its++) {
339 if (!isInserted[v]) {
341 isInserted[v] =
true;
Declaration and implementation of Array class and Array algorithms.
Includes declaration of graph class.
Decralation of GraphElement and GraphList classes.
Declaration and implementation of NodeSet, EdgeSet, and AdjEntrySet classes.
Declaration of doubly linked lists and iterators.
Basic declarations, included by all source files.
Class for adjacency list elements.
The parameterized class Array implements dynamic arrays of type E.
INDEX size() const
Returns the size (number of elements) of the array.
Data type for general directed graphs (adjacency list representation).
internal::GraphObjectContainer< NodeElement > nodes
The container containing all node objects.
Doubly linked lists (maintaining the length of the list).
iterator emplaceBack(Args &&... args)
Adds a new element at the end of the list.
void clear()
Removes all elements from the list.
Approximation algorithms for the node coloring problem in graphs.
virtual int getMaximumDegreeNode(const Graph &graph, node &maxDegreeNode) const
Searches for a maximum degree node in the graph.
unsigned int NodeColor
Data type of the node colors.
int searchBinary(SearchWrapper *searchWrapper, int start, int end) const
Performs a binary search in a specified range with a given oracle.
NodeColoringModule()
Default constructor.
virtual NodeColor getMaximumNodeColor(NodeArray< NodeColor > &colors)
Calculates the maximum node color index used in a certain node coloring.
virtual int getMinimumDegreeNodes(const Graph &graph, List< node > &minDegreeNodes) const
Searches for all nodes with minimum degree in the graph.
virtual NodeColor call(const Graph &graph, NodeArray< NodeColor > &colors, NodeColor start=0)=0
The actual algorithm call.
virtual ~NodeColoringModule()
Destructor.
SearchProcedure
Declares the search procedures.
RamseyProcedure m_ramseyProcedure
The RamseyProcedure to be used to select nodes.
virtual void ramseyAlgorithm(const Graph &graph, List< node > &clique, List< node > &independentSet) const
Performs the Ramsey algorithm for finding heuristically large cliques and independents sets in a grap...
virtual void preprocessGraph(Graph &graph) const
Preprocesses a graph so that a coloring algorithm can be applied.
void getNeighbors(const Graph &graph, LISTITERATOR nodes, List< node > &neighbors) const
Calculates the set of neighbors Y for a given set of nodes X.
RamseyProcedure
Declares the procedure of finding nodes in Ramsey's algorithm.
virtual void reverseNodeTable(const Graph &graphOrig, const Graph &graphNew, const NodeArray< node > &orig2New, NodeArray< node > &new2Orig) const
Reverses the mapping between the nodes sets of a graph and a subgraph.
bool checkIndependentSet(const Graph &graph, const CONTAINER &nodes) const
Checks if subgraph induced by the given nodes forms an independent set.
int getNeighborDegrees(const node &v) const
Calculates the sum of neighbor nodes degrees for a given node v.
virtual int getMaximumDegreeNodes(const Graph &graph, List< node > &maxDegreeNodes) const
Searches for all nodes with maximum degree in the graph.
int searchWigderson(SearchWrapper *searchWrapper) const
Performs a the search procedure specified by Wigderson.
void getNeighborsComplement(const Graph &graph, LISTITERATOR nodes, List< node > &complementNeighbors) const
Calculates the set of complement neighbors Y for a given set of nodes X.
virtual void createBuckets(const Graph &graph, int size, Array< Array< node > > &buckets) const
Creates a partitioning of the node set into buckets of a given size.
virtual int getMinimumDegreeNode(const Graph &graph, node &minDegreeNode) const
Searches for a minimum degree node in the graph.
void mergeNodeLists(const Graph &graph, LISTITERATOR firstList, LISTITERATOR secondList, List< node > &mergedList) const
Merges two lists of nodes and deletes the duplicates.
int searchLinear(SearchWrapper *searchWrapper, int start, int end) const
Performs a linear search in a specified range with a given oracle.
virtual void cliqueRemoval(const Graph &graph, List< node > &independentSet) const
Applies the clique removal algorithm for finding a large independent set in a given graph.
virtual bool checkColoring(const Graph &graph, const NodeArray< NodeColor > &colors) const
Checks if the given node coloring is valid.
Class for the representation of nodes.
internal::GraphObjectContainer< AdjElement > adjEntries
The container containing all entries in the adjacency list of this node.
const Graph * graphOf() const
Returns the graph containing this node (debug only).
bool isMember(element_type v) const
Returns true iff element v is contained in this set.
void insert(element_type v)
Inserts element v into this set.
RegisteredArray for nodes, edges and adjEntries of a graph.
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF dynamic library (shared object / DLL),...
void makeSimpleUndirected(Graph &G)
Removes all self-loops and all but one edge of each bundle of undirected parallel edges.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
The namespace for all OGDF objects.
Declaration of simple graph algorithms.
Wraps the search for the minimum parameter k so that the same code can be reused for all algorithms.
virtual bool step(int k)=0
Performs a step in the search procedure.
Struct to iterate over all node subsets of a given size.
List< node > currentSubset()
Returns the current subset.
SubsetIterator(Array< node > &set, Index subsetSize)
Creates the SubsetIterator with a given set to iterate and the size of the subsets.
bool isOk()
Returns if the iterator, i.e.
int Index
Data type for the indices.
bool advance()
Advances the iterator so that the next subset can be queried.