Prerequisites

#include <EquivalenceRelation.h>
using namespace polymake; 

Introduction

class EquivalenceRelation;

An equivalence relation on the integers 0,..,n-1 for a given size n. Initially, each element is contained in an equivalence class by itself. Two equivalence classes can be merged by specifying one (arbitrary) representative of each class. Alternatively, a set of representatives may be specified and the corresponding equivalence classes will be merged.

Each equivalence class is represented by it's smallest element (default) or alternatively by a user defined element. If classes with user defined representatives are merged, the smallest of the user defined representatives is chosen to represent the new equivalence class.

Construction

EquivalenceRelation();
Creates the equivalence relation on the empty set.
EquivalenceRelation(const int size)
Creates the equivalence relation on the integers 0,..,size-1 where each element is contained in an equivalence class by itself.
EquivalenceRelation(const int size, const Set<int>& representatives)
Creates the equivalence relation on the integers 0,..,size-1 where each element is contained in an equivalence class by itself. The representatives will be used as user defined representatives.

Modification

void merge_classes(const int e1, const int e2);
Merges two equivalence classes each represented by one (arbitrary) of it's elements.
void merge_classes(const Set<int>& elements);
Merges the classes of the elements contained in elements.
void set_representative(const int e);
The element e will be used as user defined representative of it's equivalence class.

Element access

int representative(const int e);
Return the representative of the equivalence class containing e.
Array<int> representatives();
Return the representatives of the equivalence classes of all elements.
Set<int> set_of_rep();
Return the set of all representatives.
Set<int> equivalence_class(const int e);
Return the equivalence class of the element e.
PowerSet<int> equivalence_classes();
Return all equivalence classes.
bool related(const int e1, const int e2);
Return true iff e1 and e2 are in the same equivalence class.