|
Open Graph Drawing Framework |
v. 2023.09 (Elderberry)
|
|
|
Go to the documentation of this file.
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())
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; }
148 friend class GraphListBase;
169 : m_index(pIndex), m_cardinality(0), m_hypergraph(nullptr) { }
173 int index()
const {
return m_index; }
191 template<
class NODELIST>
195 hypernodes.pushBack(
reinterpret_cast<hypernode>(adj->element()));
202 if (
reinterpret_cast<hypernode>(adj->element()) == v) {
228 friend class GraphListBase;
266 : m_index(pIndex), m_degree(0), m_type(
Type::normal), m_hypergraph(nullptr) { }
270 : m_index(pIndex), m_degree(0), m_type(pType), m_hypergraph(nullptr) { }
274 int index()
const {
return m_index; }
295 template<
class NODELIST>
299 hyperedges.pushBack(
reinterpret_cast<hyperedge>(adj->element()));
328 template<
typename Key>
330 :
public RegistryBase<Key*, HypergraphRegistry<Key>, internal::GraphIterator<Key*>> {
341 static inline int keyToIndex(Key* key) {
return key->index(); }
344 if (key ==
nullptr) {
348 if (key->hypergraph() ==
m_pGraph) {
368 const HypergraphRegistry<HypernodeElement>&
self);
371 const HypergraphRegistry<HypernodeElement>&
self);
374 const HypergraphRegistry<HyperedgeElement>&
self);
377 const HypergraphRegistry<HyperedgeElement>&
self);
380 template<
typename Key,
typename Value,
bool WithDefault,
typename Registry = HypergraphRegistry<Key>>
389 if (RA::registeredAt() ==
nullptr) {
392 return RA::registeredAt()->graphOf();
397 #define OGDF_DECL_REG_ARRAY_TYPE(v, c) HypergraphRegisteredArray<HypernodeElement, v, c>
400 #undef OGDF_DECL_REG_ARRAY_TYPE
402 #define OGDF_DECL_REG_ARRAY_TYPE(v, c) HypergraphRegisteredArray<HyperedgeElement, v, c>
405 #undef OGDF_DECL_REG_ARRAY_TYPE
445 bool empty()
const {
return m_nHypernodes == 0; }
528 hypernodeList.clear();
530 hypernodeList.pushBack(v);
537 hyperedgeList.clear();
539 hyperedgeList.pushBack(e);
544 void readBenchHypergraph(std::istream& is);
547 void readBenchHypergraph(
const char* filename);
550 void readPlaHypergraph(std::istream& is);
553 void loadPlaHypergraph(
const char* fileName);
556 bool consistency()
const;
563 return m_regHypernodeArrays;
573 return m_regHyperedgeArrays;
589 int nextEntry(
char* buffer,
int from,
string stop);
int numberOfHyperedges() const
Returns the number of hyperedges in the hypergraph.
int maxHyperedgeIndex() const
Returns the largest used hyperedge index.
Abstract base class for registries.
The namespace for all OGDF objects.
Dynamic arrays indexed with arbitrary keys.
#define OGDF_DECL_REG_ARRAY(NAME)
bool isKeyAssociated(Key *key) const
GraphElement * element() const
Returns the element associated with this adjacency entry.
T * tail() const
Returns the last element in the list.
HypergraphRegistry(Hypergraph *graph, int *nextKeyIndex)
Constructor.
void allHyperedges(LIST &hyperedgeList) const
Returns a list with all hyperedges of the hypergraph.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
void allHypernodes(LIST &hypernodeList) const
Returns a list with all hypernodes of the hypergraph.
int cardinality() const
Returns the number of incident hypernodes.
adjHypergraphEntry pred() const
Returns the predecessor in the adjacency list.
typename std::conditional< WithDefault, internal::RegisteredArrayWithDefault< HypergraphRegistry< ogdf::List< ogdf::EdgeElement > >, Value >, internal::RegisteredArrayWithoutDefault< HypergraphRegistry< ogdf::List< ogdf::EdgeElement > >, Value > >::type RA
HypergraphRegistry< HypernodeElement >::iterator begin(const HypergraphRegistry< HypernodeElement > &self)
The base class for objects used by (hyper)graphs.
int m_nHyperedges
The number of hyperedges in the hypergraph.
HypernodeElement(int pIndex, Type pType)
Constructor.
Simple, safe base classes for C++ observables and observers.
static int keyToIndex(Key *key)
RegisteredArray for nodes and edges of a hypergraph.
bool incident(hypernode v) const
Returns true iff v is incident to the hyperedge.
internal::GraphList< HyperedgeElement > m_hyperedges
The list of all hyperedges.
int m_index
The (unique) index of the adjacency entry.
HyperedgeElement(int pIndex)
Constructs an hyperedge element between hypernodes.
const HypergraphRegistry< HypernodeElement > & hypernodeRegistry() const
Returns a const reference to the registry of hypernode arrays associated with this hypergraph.
GraphElement * m_element
The associated hyperedge or hypernode.
Class for the representation of hyperedges.
const internal::GraphList< HyperedgeElement > & hyperedges() const
Returns the list of all hyperedges.
adjHypergraphEntry firstAdj() const
Returns the first entry in the adjaceny list.
int m_degree
The number of incident hyperedges.
adjHypergraphEntry succ() const
Returns the successor in the adjacency list.
const HypergraphRegistry< HyperedgeElement > & hyperedgeRegistry() const
Returns a const reference to the registry of hyperedge arrays associated with this hypergraph.
internal::GraphIterator< Key * > iterator
hypernode pred() const
Returns the predecessor in the list of all hypernodes.
internal::GraphList< AdjHypergraphElement > incidentHypernodes() const
Returns the incident hypernodes of the hyperedge.
Registry for nodes and edges of a hypergraph.
Base class for an observable object that can be tracked by multiple Observer objects.
hyperedge lastHyperEdge() const
Returns the last hyperedge in the list of all hyperedges.
void type(Type pType)
Sets the type of hypernode.
int index() const
Returns the index of a hyperedge.
int maxHypernodeIndex() const
Returns the largest used hypernode index.
int m_nHypernodes
The number of hypernodes in the hypergraph.
Class for adjacency list elements.
Type
The type of hypernodes.
int m_cardinality
The number of incidend hypernodes.
HypergraphRegistry< HypernodeElement > m_regHypernodeArrays
The registered hypernode arrays.
const internal::GraphList< HypernodeElement > & hypernodes() const
Returns the list of all hypernodes.
Hypergraph * m_hypergraph
The hypergraph containing the hypernode (if any).
Decralation of GraphElement and GraphList classes.
hyperedge firstHyperedge() const
Returns the first hyperedge in the list of all hyperedges.
HypergraphRegisteredArray< HyperedgeElement, Value, WithDefault > HyperedgeArray
Array for labeling the hyperedges in a Hypergraph with an arbitrary Value.
int m_hyperedgeIdCount
The Index that will be assigned to the next created hyperedge.
int calculateTableSize(int actualCount)
The default growth function for registered arrays.
Declaration and implementation of RegisteredArray class.
Hypergraph * hypergraph() const
Returns the hypergraph containing the hypernode.
adjHypergraphEntry twin() const
Returns the pointer to a twin adjacency list.
AdjHypergraphElement(GraphElement *pElement, int pIndex)
Constructs an adjacency entry for a given hyper{node,edge} and index.
internal::GraphList< AdjHypergraphElement > m_adjHyperedges
The adjacency list of the hypernode.
internal::GraphList< HypernodeElement > m_hypernodes
The list of all hypernodes.
Hypergraph * hypergraph() const
Returns the hypergraph containing the hyperedge.
hyperedge pred() const
Returns the predecessor in the list of all hyperedges.
std::ostream & operator<<(std::ostream &os, const ogdf::Array< E, INDEX > &a)
Prints array a to output stream os.
bool empty() const
Returns true iff the hypergraph is empty (ie. contains no hypernodes).
int numberOfHypernodes() const
Returns the number of hypernodes in the hypergraph.
int m_index
The (unique) index of the hypernode.
int index() const
Returns the (unique) hypernode index.
Doubly linked lists (maintaining the length of the list).
Lists of graph objects (like nodes, edges, etc.).
Hypergraph * m_hypergraph
The hypergraph containing the hyperedge (if any).
adjHypergraphEntry firstAdj() const
Returns the first entry in the adjaceny list.
adjHypergraphEntry m_twin
The corresponding adjacency entry.
bool adjacent(hypernode v) const
Returns true iff v is adjacent to the hypernode.
hyperedge succ() const
Returns the successor in the list of all hyperedges.
int calculateArraySize(int add) const
Hypergraph * graphOf() const
Returns a pointer to the associated hypergraph.
void allHyperedges(NODELIST &hyperedges) const
Returns a list with all incident hyperedges of the hypernode.
int index() const
Returns the index of this adjacency element.
bool operator==(const hyperedge e) const
Equality operator.
hypernode firstHypernode() const
Returns the first hypernode in the list of all hypernodes.
hypernode lastHypernode() const
Returns the last hypernode in the list of all hypernodes.
internal::GraphList< AdjHypergraphElement > m_adjHypernodes
The adjacency list of the hyperedge.
T * head() const
Returns the first element in the list.
HypergraphRegistry< HyperedgeElement > & hyperedgeRegistry()
Returns a reference to the registry of hyperedge arrays associated with this hypergraph.
bool operator==(const hypernode v) const
Equality operator.
Basic declarations, included by all source files.
int degree() const
Returns the hypernode degree.
HypergraphRegistry< HypernodeElement >::iterator end(const HypergraphRegistry< HypernodeElement > &self)
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Hypergraph * hypergraphOf() const
Returns a pointer to the associated hypergraph.
hypernode succ() const
Returns the successor in the list of all hypernodes.
void allHypernodes(NODELIST &hypernodes) const
Returns a list with all incident hypernodes of the hyperedge.
adjHypergraphEntry lastAdj() const
Returns the last entry in the adjacency list.
HypernodeElement(int pIndex)
Constructor.
HypergraphRegistry< HypernodeElement > & hypernodeRegistry()
Returns a reference to the registry of hypernode arrays associated with this hypergraph.
std::istream & operator>>(std::istream &is, TokenIgnorer token)
Type type() const
Returns the type of hypernode.
adjHypergraphEntry lastAdj() const
Returns the last entry in the adjacency list.
int getArraySize() const
Returns the current size of all registered arrays.
Type m_type
The type of the hypernode.
Declaration of memory manager for allocating small pieces of memory.
AdjHypergraphElement(GraphElement *pElement)
Constructs an adjacency element for a given hyper{node,edge}.
int m_index
The (unique) index of the hyperedge.
Class for the representation of hypernodes.
HypergraphRegistry< HyperedgeElement > m_regHyperedgeArrays
The registered hyperedge arrays.
HypergraphRegisteredArray< HypernodeElement, Value, WithDefault > HypernodeArray
Array for labeling the hypernodes in a Hypergraph with an arbitrary Value.
int m_hypernodeIdCount
The Index that will be assigned to the next created hypernode.