44#include <ogdf/basic/internal/config_autogen.h>
82#if __cpp_concepts >= 201907
86 { f(
node()) } -> std::convertible_to<bool>;
90 { f(
edge()) } -> std::convertible_to<bool>;
93concept OGDF_NODE_ITER = std::forward_iterator<T> &&
requires(T i) {
94 { *i } -> std::convertible_to<node>;
97concept OGDF_EDGE_ITER = std::forward_iterator<T> &&
requires(T i) {
98 { *i } -> std::convertible_to<edge>;
114# define OGDF_HAS_CONCEPTS
115# define OGDF_CHECK_CONCEPT static_assert
128# define OGDF_NODE_FILTER typename
129# define OGDF_EDGE_FILTER typename
130# define OGDF_NODE_ITER typename
131# define OGDF_EDGE_ITER typename
132# define OGDF_NODE_LIST typename
133# define OGDF_EDGE_LIST typename
135# define OGDF_CHECK_CONCEPT(...)
154 explicit AdjElement(
node v) : m_twin(nullptr), m_edge(nullptr), m_node(v), m_id(0) { }
157 AdjElement(
edge e,
int id) : m_twin(nullptr), m_edge(e), m_node(nullptr), m_id(id) { }
164 operator edge()
const {
return m_edge; }
170 operator node()
const {
return m_node; }
182 bool isSource()
const;
230 const Graph* graphOf()
const;
264 : m_indeg(0), m_outdeg(0), m_id(id), m_pGraph(pGraph) { }
266 NodeElement(
int id) : m_indeg(0), m_outdeg(0), m_id(id) { }
278 int indeg()
const {
return m_indeg; }
284 int degree()
const {
return m_indeg + m_outdeg; }
303 template<
class ADJLIST>
306 for (
adjEntry adj : this->adjEntries) {
307 adjList.pushBack(adj);
319 template<
class EDGELIST>
322 for (
adjEntry adj : this->adjEntries) {
323 edgeList.pushBack(adj->theEdge());
332 template<
class EDGELIST>
333 void inEdges(EDGELIST& edgeList)
const;
340 template<
class EDGELIST>
341 void outEdges(EDGELIST& edgeList)
const;
383 : m_src(src), m_tgt(tgt), m_adjSrc(adjSrc), m_adjTgt(adjTgt), m_id(id) { }
392 : m_src(src), m_tgt(tgt), m_adjSrc(nullptr), m_adjTgt(nullptr), m_id(id) { }
405 std::array<node, 2>
nodes()
const {
return std::array<node, 2> {{m_src, m_tgt}}; }
416 return v == m_src ? m_tgt : m_src;
430 return isParallelDirected(e) || isInvertedDirected(e);
452 return (m_src == e->
m_src || m_src == e->
m_tgt)
454 : ((m_tgt == e->
m_src || m_tgt == e->
m_tgt) ? m_tgt :
nullptr);
461 return v == m_src ? m_adjSrc : m_adjTgt;
472 bool m_hidden =
false;
488 bool result =
this != adjBefore &&
this != adjAfter && adjBefore != adjAfter;
492 for (; adj !=
this && adj != adjAfter; adj = adj->
cyclicSucc()) {
495 result = adj ==
this;
501template<
class EDGELIST>
505 edge e = adj->theEdge();
507 edgeList.pushBack(e);
512template<
class EDGELIST>
516 edge e = adj->theEdge();
518 edgeList.pushBack(e);
597template<
typename Key,
typename Iterable = GraphObjectContainer<Key>,
int Factor = 1>
599 :
public RegistryBase<Key*, GraphRegistry<Key, Iterable, Factor>, typename Iterable::iterator> {
610 static inline int keyToIndex(Key* key) {
return key->index(); }
613 if (key ==
nullptr) {
642#ifndef DOXYGEN_IGNORE
658template<
typename Key,
typename Value,
bool WithDefault,
typename Registry = GraphRegistry<Key>>
667 if (RA::registeredAt() ==
nullptr) {
670 return RA::registeredAt()->graphOf();
676template<
typename Value,
bool WithDefault>
683 using GRA::operator[];
684 using GRA::operator();
690 return GRA::operator[](adj->
index() >> 1);
697 return GRA::operator[](adj->
index() >> 1);
704 return GRA::operator[](adj->
index() >> 1);
711 return GRA::operator[](adj->
index() >> 1);
716template<
typename Value,
bool WithDefault>
722template<
bool WithDefault>
739#define OGDF_DECL_REG_ARRAY_TYPE(v, c) internal::GraphRegisteredArray<NodeElement, v, c>
742#undef OGDF_DECL_REG_ARRAY_TYPE
744#define OGDF_DECL_REG_ARRAY_TYPE(v, c) internal::EdgeArrayBase2<v, c>
747#undef OGDF_DECL_REG_ARRAY_TYPE
749#define OGDF_DECL_REG_ARRAY_TYPE(v, c) \
750 internal::GraphRegisteredArray<AdjElement, v, c, internal::GraphAdjRegistry>
753#undef OGDF_DECL_REG_ARRAY_TYPE
780 OGDF_DEPRECATED(
"calls registrationChanged with only partially-constructed child classes, "
781 "see copy constructor of Observer for fix")
804template<
typename CONTAINER>
805inline void getAllNodes(
const Graph& G, CONTAINER& nodes);
806template<
typename CONTAINER>
807inline void getAllEdges(
const Graph& G, CONTAINER& edges);
906 enum class EdgeType { association = 0, generalization = 1, dependency = 2 };
912 generalizationMerger = 2,
913 generalizationExpander = 3,
914 highDegreeExpander = 4,
915 lowDegreeExpander = 5,
1013 std::function<
bool(
node)> includeNode = [](
node) {
return true; },
1014 bool isFastTest =
true)
const;
1024 std::function<
bool(
edge)> includeEdge = [](
edge) {
return true; },
1025 bool isFastTest =
true)
const;
1032 template<
class CONTAINER>
1034 internal::getAllNodes<CONTAINER>(*
this, nodeContainer);
1042 template<
class CONTAINER>
1044 internal::getAllEdges<CONTAINER>(*
this, edgeContainer);
1062 node v = pureNewNode(index);
1081 return newEdge(v, Direction::after, w, Direction::after, index);
1100 return newEdge(v, Direction::after, adjTgt, Direction::after, index);
1119 return newEdge(adjSrc, Direction::after, w, Direction::after, index);
1142 return newEdge(adjSrc, dir, adjTgt, dir, index);
1164 template<
typename S,
typename T>
1168 edge e = pureNewEdge(internal::adjToNode(src), internal::adjToNode(tgt), index);
1170 insertAdjEntry(tgt, e->
m_adjTgt, dirTgt);
1171 insertAdjEntry(src, e->
m_adjSrc, dirSrc);
1233 m_it = m_graph->m_hiddenEdgeSets.pushFront(
this);
1242 m_graph->m_hiddenEdgeSets.del(m_it);
1449 template<
class NODELIST>
1451 node v = nodesToCollapse.popFrontRet();
1452 while (!nodesToCollapse.empty()) {
1453 node w = nodesToCollapse.popFrontRet();
1455 while (adj !=
nullptr) {
1460 }
else if (e->
source() == w) {
1479 template<
class ADJ_ENTRY_LIST>
1483 sort(v,
begin(newOrder),
end(newOrder));
1498 std::set<int> entries;
1501 for (
auto it =
begin; it !=
end; ++it) {
1503 entries.insert(adj->
index());
1534 adjList.
move(adjMove, adjList, adjPos, dir);
1717 bool notifyObservers =
true>
1718 std::pair<int, int> insert(
const NI& nodesBegin,
const NI& nodesEnd,
const EI& edgesBegin,
1748 template<OGDF_NODE_ITER NI, OGDF_EDGE_FILTER EF,
bool copyIDs = false,
bool notifyObservers = true>
1749 std::pair<int, int> insert(
const NI& nodesBegin,
const NI& nodesEnd,
const EF& edgeFilter,
1760 template<OGDF_NODE_LIST NL>
1770 template<OGDF_NODE_LIST NL, OGDF_EDGE_LIST EL>
1778 return insert(
begin(nodeList),
end(nodeList),
begin(edgeList),
end(edgeList), nodeMap,
1811 if (!nodeMap.registeredAt()) {
1815 if (!edgeMap.registeredAt()) {
1822 auto count = insert(G.nodes.begin(), G.nodes.end(),
filter_any_edge, nodeMap, edgeMap);
1837 return insert(G, nodeMap, edgeMap);
1841 template<OGDF_NODE_ITER NI,
bool notifyObservers,
bool copyIDs>
1843 int& newNodes,
void* cbData);
1861 virtual void*
preInsert(
bool copyEmbedding,
bool copyIDs,
bool notifyObservers,
bool edgeFilter,
1891 virtual void postInsert(
void* userData,
int newNodes,
int newEdges) {};
1928 int stopNode(
int cc)
const {
return m_startNode[cc + 1]; }
1931 return {m_nodes.
begin() + startNode(cc), m_nodes.
begin() + stopNode(cc)};
1935 return {m_edges.
begin() + startEdge(cc), m_edges.
begin() + stopEdge(cc)};
1942 int stopEdge(
int cc)
const {
return m_startEdge[cc + 1]; }
1945 node v(
int i)
const {
return m_nodes[i]; }
1948 edge e(
int i)
const {
return m_edges[i]; }
1961 index = m_nodeIdCount++;
1963 m_nodeIdCount = max(m_nodeIdCount, index + 1);
1997 index = m_edgeIdCount++;
1999 m_edgeIdCount = max(m_edgeIdCount, index + 1);
2024 if (dir == Direction::after) {
2032 if (dir == Direction::after || n->
adjEntries.empty()) {
2061template<
typename CONTAINER>
2064 for (
node v : G.nodes) {
2071 nodes.
init(G.numberOfNodes());
2073 for (
node v : G.nodes) {
2078template<
typename CONTAINER>
2081 for (
edge v : G.edges) {
2088 edges.
init(G.numberOfEdges());
2090 for (
edge v : G.edges) {
Declaration and implementation of Array class and Array algorithms.
#define OGDF_CHECK_CONCEPT(...)
Decralation of GraphElement and GraphList classes.
Implementation of the ogdf::Graph::insert(...) template methods.
Declaration of doubly linked lists and iterators.
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.
adjEntry faceCyclePred() const
Returns the cyclic predecessor in face.
adjEntry pred() const
Returns the predecessor in the adjacency list.
int index() const
Returns the index of this adjacency element.
adjEntry twin() const
Returns the corresponding adjacency element associated with the same edge.
bool isBetween(adjEntry adjBefore, adjEntry adjAfter) const
Returns whether this adjacency entry lies between adjBefore and adjAfter in clockwise rotation.
adjEntry clockwiseFaceSucc() const
Returns the clockwise successor in face. Use faceCycleSucc instead!
AdjElement * m_twin
The corresponding adjacency entry (same edge)
int m_id
The (unique) index of the adjacency entry.
adjEntry counterClockwiseFaceSucc() const
Returns the counter-clockwise successor in face.
static int compare(const AdjElement &x, const AdjElement &y)
Standard Comparer.
edge m_edge
The associated edge.
adjEntry counterClockwiseFacePred() const
Returns the counter-clockwise predecessor in face.
adjEntry cyclicSucc() const
Returns the cyclic successor in the adjacency list.
AdjElement(node v)
Constructs an adjacency element for a given node.
adjEntry succ() const
Returns the successor in the adjacency list.
edge theEdge() const
Returns the edge associated with this adjacency entry.
adjEntry clockwiseFacePred() const
Returns the clockwise predecessor in face. Use faceCycleSucc instead!
bool isSource() const
Returns true iff this is the source adjacency entry of the corresponding edge.
node m_node
The node whose adjacency list contains this entry.
const Graph * graphOf() const
adjEntry cyclicPred() const
Returns the cyclic predecessor in the adjacency list.
node twinNode() const
Returns the associated node of the corresponding adjacency entry (shorthand for twin()->theNode()).
node theNode() const
Returns the node whose adjacency list contains this element.
adjEntry faceCycleSucc() const
Returns the cyclic successor in face.
AdjElement(edge e, int id)
Constructs an adjacency entry for a given edge and index.
The parameterized class Array implements dynamic arrays of type E.
iterator begin()
Returns an iterator to the first element.
void init()
Reinitializes the array to an array with empty index set.
Abstract base class for bucket functions.
Bucket function using the index of an edge's source node as bucket.
int getBucket(const edge &e) override
Returns source index of e.
Bucket function using the index of an edge's target node as bucket.
int getBucket(const edge &e) override
Returns target index of e.
Class for the representation of edges.
adjEntry adjSource() const
Returns the corresponding adjacancy entry at source node.
bool isParallelDirected(edge e) const
Returns true iff edge e is parallel to this (directed) edge (or if it is the same edge)
int index() const
Returns the index of the edge.
EdgeElement(node src, node tgt, int id)
Constructs an edge element (src,tgt).
node opposite(node v) const
Returns the adjacent node different from v.
EdgeElement(node src, node tgt, AdjElement *adjSrc, AdjElement *adjTgt, int id)
Constructs an edge element (src,tgt).
edge succ() const
Returns the successor in the list of all edges.
const Graph * graphOf() const
Returns the graph containing this node (debug only).
AdjElement * m_adjSrc
Corresponding adjacency entry at source node.
std::array< node, 2 > nodes() const
Returns a list of adjacent nodes. If this edge is a self-loop, both entries will be the same node.
bool isAdjacent(edge e) const
Returns true iff e is adjacent to the edge.
AdjElement * m_adjTgt
Corresponding adjacency entry at target node.
bool isIncident(node v) const
Returns true iff v is incident to the edge.
node m_tgt
The target node of the edge.
adjEntry adjTarget() const
Returns the corresponding adjacancy entry at target node.
node m_src
The source node of the edge.
static int compare(const EdgeElement &x, const EdgeElement &y)
Standard Comparer.
edge pred() const
Returns the predecessor in the list of all edges.
node commonNode(edge e) const
Returns the common node of the edge and e. Returns nullptr if the two edges are not adjacent.
bool isInvertedDirected(edge e) const
Returns true iff edge e is an inverted edge to this (directed) edge.
bool isParallelUndirected(edge e) const
Returns true iff edge e is parallel to this (undirected) edge (or if it is the same edge)
bool isSelfLoop() const
Returns true iff the edge is a self-loop (source node = target node).
node target() const
Returns the target node of the edge.
adjEntry getAdj(node v) const
Returns an adjacency entry of this edge at node v. If this is a self-loop the source adjacency entry ...
node source() const
Returns the source node of the edge.
Info structure for maintaining connected components.
int numberOfNodes(int cc) const
Returns the number of nodes in connected component cc.
int numberOfEdges(int cc) const
Returns the number of edges in connected component cc.
Array< node > m_nodes
array of all nodes.
edge e(int i) const
Returns the edge with index i.
CCsInfo()
Creates a info structure associated with no graph.
int m_numCC
the number of connected components.
internal::SimpleRange< Array< edge >::const_iterator > edges(int cc) const
int numberOfCCs() const
Returns the number of connected components.
CCsInfo(const Graph &G)
Creates a info structure associated with graph G.
const Graph & constGraph() const
Returns the associated graph.
node v(int i) const
Returns the node with index i.
Array< int > m_startEdge
start edge of each connected component in m_edges.
Array< int > m_startNode
start node of each connected component in m_nodes.
Array< edge > m_edges
array of all edges.
int stopNode(int cc) const
Returns the index of (one past) the last node in connected component cc.
int stopEdge(int cc) const
Returns the index of (one past) the last edge in connected component cc.
int startNode(int cc) const
Returns the index of the first node in connected component cc.
internal::SimpleRange< Array< node >::const_iterator > nodes(int cc) const
int startEdge(int cc) const
Returns the index of the first edge in connected component cc.
const Graph * m_graph
points to the associated graph.
Functionality for temporarily hiding edges in constant time.
bool empty()
Checks whether this set is empty.
void hide(edge e)
Hides the given edge.
~HiddenEdgeSet()
Restores all hidden edges.
internal::GraphList< EdgeElement >::iterator begin()
Return an iterator to the first hidden edge in this set.
void restore(edge e)
Reveals the given edge.
ListIterator< HiddenEdgeSet * > m_it
HiddenEdgeSet(Graph &graph)
Creates a new set of hidden edges.
internal::GraphList< EdgeElement >::iterator end()
Return an iterator one past the last hidden edge in this set.
int size()
Returns the number of edges contained in this set.
internal::GraphList< EdgeElement > m_edges
void restore()
Restores all edges contained in this set.
Iterator for AdjEntries of a graph.
AdjElement & operator->() const
Returns a reference to the associated adjElement.
bool operator!=(const GraphAdjIterator &iter) const
Inequality operator.
bool operator==(const GraphAdjIterator &iter) const
Equality operator.
adjEntry operator*() const
Returns the associated adjEntry.
void next()
Proceeds to the next adjEntry.
GraphAdjIterator & operator++()
Increment operator (prefix).
GraphAdjIterator & operator--()
Decrement operator (prefix).
GraphAdjIterator operator--(int)
Decrement operator (postfix).
void prev()
Returns to the previous adjEntry.
GraphAdjIterator end()
Returns an iterator to the one-past-last adjEntry in the associated graph.
GraphAdjIterator(Graph *graph=nullptr, adjEntry entry=nullptr)
Constructor.
GraphAdjIterator operator++(int)
Increment operator (postfix).
GraphAdjIterator begin()
Returns an iterator to the first adjEntry in the associated graph.
Data type for general directed graphs (adjacency list representation).
edge newEdge(node v, adjEntry adjTgt, int index=-1)
Creates a new edge at predefined positions in the adjacency lists.
node contract(edge e, bool keepSelfLoops=false)
Contracts edge e while preserving the order of adjacency entries.
int maxNodeIndex() const
Returns the largest used node index.
virtual void unsplit(edge eIn, edge eOut)
Undoes a split operation.
internal::GraphNodeRegistry & nodeRegistry()
Returns a reference to the registry of node arrays associated with this graph.
internal::GraphEdgeRegistry & edgeRegistry()
Returns a reference to the registry of edge arrays associated with this graph.
void unsplit(node u)
Undoes a split operation.
edge newEdge(adjEntry adjSrc, node w, int index=-1)
Creates a new edge at predefined positions in the adjacency lists.
node splitNode(adjEntry adjStartLeft, adjEntry adjStartRight)
Splits a node while preserving the order of adjacency entries.
node chooseNode(std::function< bool(node)> includeNode=[](node) { return true;}, bool isFastTest=true) const
Returns a random node.
node lastNode() const
Returns the last node in the list of all nodes.
int numberOfNodes() const
Returns the number of nodes in the graph.
internal::GraphEdgeRegistry m_regEdgeArrays
The registered edge arrays.
void moveSource(edge e, node w)
Moves the source node of edge e to node w.
void sort(node v, const ADJ_ENTRY_LIST &newOrder)
Sorts the adjacency list of node v according to newOrder.
edge lastEdge() const
Returns the last edge in the list of all edges.
edge firstEdge() const
Returns the first edge in the list of all edges.
void moveAdjBefore(adjEntry adjMove, adjEntry adjBefore)
Moves adjacency entry adjMove before adjBefore.
void collapse(NODELIST &nodesToCollapse)
Collapses all nodes in the list nodesToCollapse to the first node in the list.
void swapAdjEdges(adjEntry adj1, adjEntry adj2)
Exchanges two entries in an adjacency list.
virtual void clear()
Removes all nodes and all edges from the graph.
static void insertAdjEntry(node n, adjEntry newAdj, Direction dir)
int maxEdgeIndex() const
Returns the largest used edge index.
void moveTarget(edge e, node w)
Moves the target node of edge e to node w.
void allEdges(CONTAINER &edgeContainer) const
Returns a container with all edges of the graph.
virtual void delNode(node v)
Removes node v and all incident edges from the graph.
void move(edge e, adjEntry adjSrc, Direction dirSrc, adjEntry adjTgt, Direction dirTgt)
Moves edge e to a different adjacency list.
void reverseEdge(edge e)
Reverses the edge e, i.e., exchanges source and target node.
edge newEdge(adjEntry adjSrc, adjEntry adjTgt, Direction dir=Direction::after, int index=-1)
Creates a new edge at predefined positions in the adjacency lists.
internal::GraphAdjRegistry m_regAdjArrays
The registered adjEntry arrays.
void resetNodeIdCount(int maxId)
int maxAdjEntryIndex() const
Returns the largest used adjEntry index.
int m_edgeIdCount
The Index that will be assigned to the next created edge.
int m_nodeIdCount
The Index that will be assigned to the next created node.
virtual void postInsert(void *userData, int newNodes, int newEdges)
Callback notifying subclasses that an insert() call has finished.
int numberOfEdges() const
Returns the number of edges in the graph.
bool representsCombEmbedding() const
Returns true iff the graph represents a combinatorial embedding.
void resetEdgeIdCount(int maxId)
Resets the edge id count to maxId.
List< HiddenEdgeSet * > m_hiddenEdgeSets
The list of hidden edges.
virtual void nodeInserted(void *userData, node original, node copy)
Callback notifying subclasses that insert() copied a node.
void reverseAdjEdges()
Reverses all adjacency lists.
std::pair< int, int > insert(const Graph &G)
Inserts a copy of a given Graph G into this graph.
internal::GraphObjectContainer< NodeElement > nodes
The container containing all node objects.
std::pair< int, int > insert(const NL &nodeList, const EL &edgeList, NodeArray< node > &nodeMap, EdgeArray< edge > &edgeMap)
Inserts a copy of a given subgraph into this graph.
void moveTarget(edge e, adjEntry adjTgt, Direction dir)
Moves the target node of edge e to a specific position in an adjacency list.
void sort(node v, IT begin, IT end)
Sorts the adjacency list of node v according to the range denoted by two iterators.
void allNodes(CONTAINER &nodeContainer) const
Returns a container with all nodes of the graph.
virtual void delEdge(edge e)
Removes edge e from the graph.
const internal::GraphNodeRegistry & nodeRegistry() const
Returns a const reference to the registry of node arrays associated with this graph.
edge chooseEdge(std::function< bool(edge)> includeEdge=[](edge) { return true;}, bool isFastTest=true) const
Returns a random edge.
void moveAdj(adjEntry adjMove, Direction dir, adjEntry adjPos)
Moves adjacency entry adjMove before or after adjPos.
node newNode(int index=-1)
Creates a new node and returns it.
static void insertAdjEntry(adjEntry oldAdj, adjEntry newAdj, Direction dir)
node firstNode() const
Returns the first node in the list of all nodes.
edge newEdge(node v, node w, int index=-1)
Creates a new edge (v,w) and returns it.
void consistencyCheck() const
Asserts that this graph is consistent.
Graph()
Constructs an empty graph.
internal::GraphAdjRegistry & adjEntryRegistry()
Returns a reference to the registry of adjEntry arrays associated with this graph.
std::pair< int, int > insert(const CCsInfo &info, int cc, NodeArray< node > &nodeMap, EdgeArray< edge > &edgeMap)
Inserts a copy of a given connected component cc into this graph.
void reverseAdjEdges(node v)
Reverses the adjacency list of v.
NodeType
The type of nodes.
virtual edge split(edge e)
Splits edge e into two edges introducing a new node.
internal::GraphNodeRegistry m_regNodeArrays
The registered node arrays.
void moveAdjAfter(adjEntry adjMove, adjEntry adjAfter)
Moves adjacency entry adjMove after adjAfter.
bool empty() const
Returns true iff the graph is empty, i.e., contains no nodes.
void reverseAllEdges()
Reverses all edges in the graph.
EdgeType
The type of edges (only used in derived classes).
const internal::GraphAdjRegistry & adjEntryRegistry() const
Returns a const reference to the registry of adjEntry arrays associated with this graph.
edge pureNewEdge(node src, node tgt, int index)
Creates a new edge object with id index and corresponding AdjElements and adds it to the list of edge...
node pureNewNode(int index)
Creates a new node object with id index and adds it to the list of nodes.
virtual ~Graph()
Destructor.
void restoreAllEdges()
Restore all hidden edges and invalidate all HiddenEdgeSets.
void moveSource(edge e, adjEntry adjSrc, Direction dir)
Moves the source node of edge e to a specific position in an adjacency list.
edge searchEdge(node v, node w, bool directed=false) const
Searches and returns an edge connecting nodes v and w in time O( min(deg(v ), deg(w ))).
void moveAdj(adjEntry adj, node w)
moves adjacency entry to node w
virtual void edgeInserted(void *userData, edge original, edge copy)
Callback notifying subclasses that insert() copied an edge.
edge newEdge(S src, Direction dirSrc, T tgt, Direction dirTgt, int index=-1)
Creates a new edge at predefined positions in the adjacency lists.
std::pair< int, int > insert(const Graph &G, NodeArray< node > &nodeMap, EdgeArray< edge > &edgeMap)
Inserts a copy of a given Graph G into this graph.
internal::GraphObjectContainer< EdgeElement > edges
The container containing all edge objects.
int genus() const
Returns the genus of the graph's embedding.
virtual void * preInsert(bool copyEmbedding, bool copyIDs, bool notifyObservers, bool edgeFilter, NodeArray< node > &nodeMap, EdgeArray< edge > &edgeMap, int *newNodes, int *newEdges)
Callback notifying subclasses that some graph is about to be insert() -ed.
const internal::GraphEdgeRegistry & edgeRegistry() const
Returns a const reference to the registry of edge arrays associated with this graph.
Abstract Base class for graph observers.
const Graph * getGraph() const
virtual void edgeDeleted(edge e)=0
Called by watched graph just before an edge is deleted.
GraphObserver()=default
Constructs instance of GraphObserver class.
virtual void nodeDeleted(node v)=0
Called by watched graph just before a node is deleted.
virtual void edgeAdded(edge e)=0
Called by watched graph after an edge has been added.
virtual void nodeAdded(node v)=0
Called by watched graph after a node has been added.
virtual void cleared()=0
Called by watched graph when its clear function is called, just before things are removed.
Doubly linked lists (maintaining the length of the list).
Encapsulates a pointer to a list element.
Class for the representation of nodes.
void allAdjEntries(ADJLIST &adjList) const
Returns a list with all adjacency entries of this node.
void adjEdges(EDGELIST &edgeList) const
Returns a list with all edges incident to this node.
void inEdges(EDGELIST &edgeList) const
Returns a list with all incoming edges of this node.
int m_id
The (unique) index of the node.
NodeElement(const Graph *pGraph, int id)
Constructs a node element with index id.
const Graph * m_pGraph
The graph containg this node (debug only).
int indeg() const
Returns the indegree of the node.
int degree() const
Returns the degree of the node (indegree + outdegree).
void outEdges(EDGELIST &edgeList) const
Returns a list with all outgoing edges of this node.
internal::GraphObjectContainer< AdjElement > adjEntries
The container containing all entries in the adjacency list of this node.
node succ() const
Returns the successor in the list of all nodes.
int index() const
Returns the (unique) node index.
adjEntry firstAdj() const
Returns the first entry in the adjaceny list.
const Graph * graphOf() const
Returns the graph containing this node (debug only).
adjEntry lastAdj() const
Returns the last entry in the adjacency list.
node pred() const
Returns the predecessor in the list of all nodes.
int m_indeg
The indegree of the node.
static int compare(const NodeElement &x, const NodeElement &y)
Standard Comparer.
int outdeg() const
Returns the outdegree of the node.
int m_outdeg
The outdegree of the node.
Base class for an observable object that can be tracked by multiple Observer objects.
Base class for an observer for a single Observable object.
Dynamic arrays indexed with arbitrary keys.
typename std::conditional< WithDefault, internal::RegisteredArrayWithDefault< Registry, Value >, internal::RegisteredArrayWithoutDefault< Registry, Value > >::type RA
void init(const Base *base=nullptr)
Reinitializes the array. Associates the array with the matching registry of base.
Abstract base class for registries.
void keyAdded(Key key)
Records the addition of a new key and resizes all registered arrays if necessary.
void reserveSpace(int new_keys)
Resizes all arrays to make space of new_keys new keys.
int getArraySize() const
Returns the current size of all registered arrays.
RegisteredArray for edges of a graph.
const Value & operator()(adjEntry adj) const
Returns a const reference to the element associated with the edge corresponding to adj.
Value & operator[](adjEntry adj)
Returns a reference to the element associated with the edge corresponding to adj.
Value & operator()(adjEntry adj)
Returns a reference to the element associated with the edge corresponding to adj.
const Value & operator[](adjEntry adj) const
Returns a const reference to the element associated with the edge corresponding to adj.
adjEntry mapEndpoint(adjEntry adj) const
Map a source/target adjEntry to the source/target adjEntry of the corresponding edges.
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
The base class for objects used by (hyper)graphs.
GraphElement * m_next
The successor in the list.
GraphElement * m_prev
The predecessor in the list.
Base class for GraphElement lists.
Lists of graph objects (like nodes, edges, etc.).
T * head() const
Returns the first element in the list.
void move(T *pX, GraphList< T > &L, T *pY, Direction dir)
Moves element pX to list L and inserts it before or after pY.
T * tail() const
Returns the last element in the list.
bool empty() const
Returns true iff the list is empty.
void pushBack(T *pX)
Adds element pX at the end of the list.
int size() const
Returns the size of the list.
Public read-only interface for lists of graph objects.
RegisteredArray for nodes, edges and adjEntries of a graph.
Graph * graphOf() const
Returns a pointer to the associated graph.
Registry for nodes, edges and adjEntries of a graph.
bool isKeyAssociated(Key *key) const
static int keyToIndex(Key *key)
int calculateArraySize(int add) const
typename Iterable::iterator iterator
Graph * graphOf() const
Returns a pointer to the associated graph.
GraphRegistry(Graph *graph, int *nextKeyIndex)
Constructor.
Declarations for Comparer objects.
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF dynamic library (shared object / DLL),...
Utility macros for declaring copy and move constructors and assignment operations.
#define OGDF_COPY_CONSTR(cls)
Declares the copy constructor for class cls.
#define OGDF_COPY_OP(cls)
Declares the copy assignment operation for class cls. Don't forget to return *this;.
#define OGDF_NO_COPY(cls)
Explicitly disables (deletes) copy construction and assignment for class cls.
#define OGDF_NO_MOVE(cls)
Explicitly disables (deletes) move construction and assignment for class cls.
Decralation of graph iterators.
#define OGDF_AUGMENT_STATICCOMPARER(type)
Add this macro to your class to turn it into a full static comparer.
NodeElement * node
The type of nodes.
EdgeElement * edge
The type of edges.
#define OGDF_DEPRECATED(reason)
Mark a class / member / function as deprecated.
#define OGDF_MALLOC_NEW_DELETE
Makes the class use malloc for memory allocation.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
#define OGDF_NEW_DELETE
Makes the class use OGDF's memory allocator.
Declaration of memory manager for allocating small pieces of memory.
node adjToNode(adjEntry adj)
void getAllNodes(const Graph &G, CONTAINER &nodes)
void getAllEdges(const Graph &G, CONTAINER &edges)
The namespace for all OGDF objects.
std::ostream & operator<<(std::ostream &os, const ogdf::Array< E, INDEX > &a)
Prints array a to output stream os.
HypergraphRegistry< HypernodeElement >::iterator begin(const HypergraphRegistry< HypernodeElement > &self)
int calculateTableSize(int actualCount)
The default growth function for registered arrays.
void copyEmbedding(const Graph &from, Graph &to, std::function< adjEntry(adjEntry)> adjMapFromTo)
bool operator==(const Tuple2< E1, E2 > &t1, const Tuple2< E1, E2 > &t2)
Equality operator for 2-tuples.
bool filter_any_edge(edge e)
std::function<bool(edge)> that returns true for any edge e
HypergraphRegistry< HypernodeElement >::iterator end(const HypergraphRegistry< HypernodeElement > &self)
bool filter_any_node(node n)
std::function<bool(node)> that returns true for any node n
NodePair(node src, node tgt)