51#define forall_adj_elements(adj, ge) for ((adj) = (v)->firstAdj(); (adj); (adj) = (adj)->succ())
54#define forall_hypernodes(v, H) for ((v) = (H).firstHypernode(); (v); (v) = (v)->succ())
57#define forall_rev_hypernodes(v, H) for ((v) = (H).lastHypernode(); (v); (v) = (v)->pred())
60#define forall_hyperedges(e, H) for ((e) = (H).firstHyperedge(); (e); (e) = (e)->succ())
63#define forall_rev_hyperedges(e, H) for ((e) = (H).lastHyperedge(); (e); (e) = (e)->pred())
67class AdjHypergraphElement;
68class HyperedgeElement;
70class HypernodeElement;
88 friend class GraphListBase;
109 : m_element(pElement), m_twin(nullptr), m_index(0) { }
113 : m_element(pElement), m_twin(nullptr), m_index(pIndex) { }
117 int index()
const {
return m_index; }
125 GraphElement*
element()
const {
return m_element; }
150 friend class GraphListBase;
171 : m_index(pIndex), m_cardinality(0), m_hypergraph(nullptr) { }
175 int index()
const {
return m_index; }
193 template<
class NODELIST>
197 hypernodes.pushBack(
reinterpret_cast<hypernode>(adj->element()));
204 if (
reinterpret_cast<hypernode>(adj->element()) == v) {
230 friend class GraphListBase;
268 : m_index(pIndex), m_degree(0), m_type(
Type::normal), m_hypergraph(nullptr) { }
272 : m_index(pIndex), m_degree(0), m_type(pType), m_hypergraph(nullptr) { }
276 int index()
const {
return m_index; }
297 template<
class NODELIST>
301 hyperedges.pushBack(
reinterpret_cast<hyperedge>(adj->element()));
332template<
typename Key>
334 :
public RegistryBase<Key*, HypergraphRegistry<Key>, internal::GraphIterator<Key*>> {
345 static inline int keyToIndex(Key* key) {
return key->index(); }
348 if (key ==
nullptr) {
352 if (key->hypergraph() ==
m_pGraph) {
384template<
typename Key,
typename Value,
bool WithDefault,
typename Registry = HypergraphRegistry<Key>>
393 if (RA::registeredAt() ==
nullptr) {
396 return RA::registeredAt()->graphOf();
401#define OGDF_DECL_REG_ARRAY_TYPE(v, c) HypergraphRegisteredArray<HypernodeElement, v, c>
404#undef OGDF_DECL_REG_ARRAY_TYPE
406#define OGDF_DECL_REG_ARRAY_TYPE(v, c) HypergraphRegisteredArray<HyperedgeElement, v, c>
409#undef OGDF_DECL_REG_ARRAY_TYPE
449 bool empty()
const {
return m_nHypernodes == 0; }
532 hypernodeList.clear();
534 hypernodeList.pushBack(v);
541 hyperedgeList.clear();
543 hyperedgeList.pushBack(e);
567 return m_regHypernodeArrays;
577 return m_regHyperedgeArrays;
Decralation of GraphElement and GraphList classes.
Simple, safe base classes for C++ observables and observers.
Declaration and implementation of RegisteredArray class.
#define OGDF_DECL_REG_ARRAY(NAME)
Basic declarations, included by all source files.
Class for adjacency list elements.
GraphElement * m_element
The associated hyperedge or hypernode.
adjHypergraphEntry cyclicSucc() const
Returns the cyclic successor in the adjacency list.
adjHypergraphEntry succ() const
Returns the successor in the adjacency list.
int index() const
Returns the index of this adjacency element.
adjHypergraphEntry twin() const
Returns the pointer to a twin adjacency list.
adjHypergraphEntry m_twin
The corresponding adjacency entry.
int m_index
The (unique) index of the adjacency entry.
adjHypergraphEntry pred() const
Returns the predecessor in the adjacency list.
friend std::ostream & operator<<(std::ostream &os, ogdf::adjHypergraphEntry v)
adjHypergraphEntry cyclicPred() const
Returns the cyclic predecessor in the adjacency list.
AdjHypergraphElement(GraphElement *pElement, int pIndex)
Constructs an adjacency entry for a given hyper{node,edge} and index.
GraphElement * element() const
Returns the element associated with this adjacency entry.
AdjHypergraphElement(GraphElement *pElement)
Constructs an adjacency element for a given hyper{node,edge}.
Class for the representation of hyperedges.
internal::GraphList< AdjHypergraphElement > m_adjHypernodes
The adjacency list of the hyperedge.
void allHypernodes(NODELIST &hypernodes) const
Returns a list with all incident hypernodes of the hyperedge.
Hypergraph * hypergraph() const
Returns the hypergraph containing the hyperedge.
adjHypergraphEntry lastAdj() const
Returns the last entry in the adjacency list.
int cardinality() const
Returns the number of incident hypernodes.
hyperedge pred() const
Returns the predecessor in the list of all hyperedges.
int m_cardinality
The number of incidend hypernodes.
bool incident(hypernode v) const
Returns true iff v is incident to the hyperedge.
friend std::ostream & operator<<(std::ostream &os, ogdf::hyperedge e)
internal::GraphList< AdjHypergraphElement > incidentHypernodes() const
Returns the incident hypernodes of the hyperedge.
hyperedge succ() const
Returns the successor in the list of all hyperedges.
Hypergraph * m_hypergraph
The hypergraph containing the hyperedge (if any).
adjHypergraphEntry firstAdj() const
Returns the first entry in the adjaceny list.
bool operator==(const hyperedge e) const
Equality operator.
int index() const
Returns the index of a hyperedge.
int m_index
The (unique) index of the hyperedge.
HyperedgeElement(int pIndex)
Constructs an hyperedge element between hypernodes.
void delHyperedge(hyperedge e)
Removes hyperedge e from the hypergraph.
void loadPlaHypergraph(const char *fileName)
Reads hypergraph in pla format from the file.
hyperedge lastHyperEdge() const
Returns the last hyperedge in the list of all hyperedges.
hyperedge randomHyperedge() const
Returns a randomly chosen hyperedge.
void clear()
Removes all hypernodes and all hyperedges from the hypergraph.
const internal::GraphList< HypernodeElement > & hypernodes() const
Returns the list of all hypernodes.
hyperedge firstHyperedge() const
Returns the first hyperedge in the list of all hyperedges.
int maxHyperedgeIndex() const
Returns the largest used hyperedge index.
hypernode newHypernode(int pIndex, HypernodeElement::Type pType)
Creates a new hypernode with given pIndex and pType and returns it.
int m_hyperedgeIdCount
The Index that will be assigned to the next created hyperedge.
HypergraphRegistry< HypernodeElement > m_regHypernodeArrays
The registered hypernode arrays.
int m_hypernodeIdCount
The Index that will be assigned to the next created hypernode.
HypergraphRegistry< HyperedgeElement > m_regHyperedgeArrays
The registered hyperedge arrays.
internal::GraphList< HyperedgeElement > m_hyperedges
The list of all hyperedges.
int m_nHypernodes
The number of hypernodes in the hypergraph.
void allHyperedges(LIST &hyperedgeList) const
Returns a list with all hyperedges of the hypergraph.
bool empty() const
Returns true iff the hypergraph is empty (ie. contains no hypernodes).
hypernode newHypernode(HypernodeElement::Type pType)
Creates a new hypernode with given pType and returns it.
int numberOfHyperedges() const
Returns the number of hyperedges in the hypergraph.
internal::GraphList< HypernodeElement > m_hypernodes
The list of all hypernodes.
friend std::istream & operator>>(std::istream &is, ogdf::Hypergraph &H)
const HypergraphRegistry< HypernodeElement > & hypernodeRegistry() const
Returns a const reference to the registry of hypernode arrays associated with this hypergraph.
void readBenchHypergraph(std::istream &is)
Reads hypergraph in bench format from the input stream.
bool consistency() const
Checks the consistency of the data structure.
Hypergraph & operator=(const Hypergraph &H)
friend std::ostream & operator<<(std::ostream &os, ogdf::Hypergraph &H)
Hypergraph(const Hypergraph &H)
Constructs a hypergraph that is a copy of H.
hypernode lastHypernode() const
Returns the last hypernode in the list of all hypernodes.
int nextEntry(char *buffer, int from, string stop)
void allHypernodes(LIST &hypernodeList) const
Returns a list with all hypernodes of the hypergraph.
hypernode newHypernode()
Creates a new hypernode and returns it.
int maxHypernodeIndex() const
Returns the largest used hypernode index.
int numberOfHypernodes() const
Returns the number of hypernodes in the hypergraph.
HypernodeElement::Type gateType(string gate)
hyperedge newHyperedge(int pIndex, List< hypernode > &hypernodes)
Creates a new hyperedge between hypernodes and returns it.
void readPlaHypergraph(std::istream &is)
Reads hypergraph in pla format from the input stream.
void readBenchHypergraph(const char *filename)
Reads hypergraph in bench format from the file.
const HypergraphRegistry< HyperedgeElement > & hyperedgeRegistry() const
Returns a const reference to the registry of hyperedge arrays associated with this hypergraph.
hypernode firstHypernode() const
Returns the first hypernode in the list of all hypernodes.
const internal::GraphList< HyperedgeElement > & hyperedges() const
Returns the list of all hyperedges.
HypergraphRegistry< HypernodeElement > & hypernodeRegistry()
Returns a reference to the registry of hypernode arrays associated with this hypergraph.
Hypergraph()
Constructs an empty hypergraph.
void delHypernode(hypernode v)
Removes hypernode v and all incident hyperedges from the hypergraph.
HypergraphRegistry< HyperedgeElement > & hyperedgeRegistry()
Returns a reference to the registry of hyperedge arrays associated with this hypergraph.
hyperedge newHyperedge(List< hypernode > &hypernodes)
Creates a new hyperedge btween hypernodes and returns it.
hypernode randomHypernode() const
Returns a randomly chosen hypergraph.
hypernode newHypernode(int pIndex)
Creates a new hypernode with given pIndex and returns it.
int m_nHyperedges
The number of hyperedges in the hypergraph.
RegisteredArray for nodes and edges of a hypergraph.
Hypergraph * hypergraphOf() const
Returns a pointer to the associated hypergraph.
Registry for nodes and edges of a hypergraph.
HypergraphRegistry(Hypergraph *graph, int *nextKeyIndex)
Constructor.
Hypergraph * graphOf() const
Returns a pointer to the associated hypergraph.
bool isKeyAssociated(Key *key) const
int calculateArraySize(int add) const
static int keyToIndex(Key *key)
Class for the representation of hypernodes.
HypernodeElement(int pIndex, Type pType)
Constructor.
int index() const
Returns the (unique) hypernode index.
void type(Type pType)
Sets the type of hypernode.
int m_degree
The number of incident hyperedges.
int m_index
The (unique) index of the hypernode.
hypernode pred() const
Returns the predecessor in the list of all hypernodes.
hypernode succ() const
Returns the successor in the list of all hypernodes.
Type m_type
The type of the hypernode.
adjHypergraphEntry lastAdj() const
Returns the last entry in the adjacency list.
HypernodeElement(int pIndex)
Constructor.
adjHypergraphEntry firstAdj() const
Returns the first entry in the adjaceny list.
Hypergraph * hypergraph() const
Returns the hypergraph containing the hypernode.
void allHyperedges(NODELIST &hyperedges) const
Returns a list with all incident hyperedges of the hypernode.
Type type() const
Returns the type of hypernode.
friend std::ostream & operator<<(std::ostream &os, ogdf::hypernode v)
bool adjacent(hypernode v) const
Returns true iff v is adjacent to the hypernode.
internal::GraphList< AdjHypergraphElement > m_adjHyperedges
The adjacency list of the hypernode.
int degree() const
Returns the hypernode degree.
Hypergraph * m_hypergraph
The hypergraph containing the hypernode (if any).
Type
The type of hypernodes.
bool operator==(const hypernode v) const
Equality operator.
Doubly linked lists (maintaining the length of the list).
Base class for an observable object that can be tracked by multiple Observer objects.
Dynamic arrays indexed with arbitrary keys.
typename std::conditional< WithDefault, internal::RegisteredArrayWithDefault< Registry, Value >, internal::RegisteredArrayWithoutDefault< Registry, Value > >::type RA
Abstract base class for registries.
int getArraySize() const
Returns the current size of all registered arrays.
The base class for objects used by (hyper)graphs.
Lists of graph objects (like nodes, edges, etc.).
T * head() const
Returns the first element in the list.
T * tail() const
Returns the last element in the list.
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF dynamic library (shared object / DLL),...
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Declaration of memory manager for allocating small pieces of memory.
The namespace for all OGDF objects.
HypergraphRegistry< HypernodeElement >::iterator begin(const HypergraphRegistry< HypernodeElement > &self)
int calculateTableSize(int actualCount)
The default growth function for registered arrays.
HypergraphRegistry< HypernodeElement >::iterator end(const HypergraphRegistry< HypernodeElement > &self)