98 operator edge()
const {
return m_edge; }
102 operator node()
const {
return m_node; }
114 bool isSource()
const;
158 const Graph *graphOf()
const;
180 const Graph *m_pGraph;
192 m_indeg(0), m_outdeg(0), m_id(id), m_pGraph(pGraph) { }
206 int indeg()
const {
return m_indeg; }
210 int degree()
const {
return m_indeg + m_outdeg; }
227 template<
class ADJLIST>
230 for(
adjEntry adj : this->adjEntries) {
231 adjList.pushBack(adj);
243 template<
class EDGELIST>
246 for(
adjEntry adj : this->adjEntries) {
247 edgeList.pushBack(adj->theEdge());
256 template<
class EDGELIST>
257 void inEdges(EDGELIST &edgeList)
const;
264 template<
class EDGELIST>
265 void outEdges(EDGELIST &edgeList)
const;
268 const Graph *graphOf()
const {
return m_pGraph; }
281 return (m_next) ?
static_cast<adjEntry>(m_next) : m_node->firstAdj();
286 return (m_prev) ?
static_cast<adjEntry>(m_prev) : m_node->lastAdj();
311 m_src(src), m_tgt(tgt), m_adjSrc(adjSrc), m_adjTgt(adjTgt), m_id(id) { }
320 m_src(src), m_tgt(tgt), m_id(id) { }
330 std::array<node, 2>
nodes()
const {
return std::array<node, 2>{{m_src, m_tgt}}; }
358 const Graph *graphOf()
const {
return m_src->graphOf(); }
375 return v == m_src ? m_adjSrc : m_adjTgt;
386 bool m_hidden =
false;
391 inline const Graph *AdjElement::graphOf()
const {
392 return m_node->graphOf();
397 return this == m_edge->adjSource();
402 node v = this->theNode();
406 bool result =
this != adjBefore &&
this != adjAfter && adjBefore != adjAfter;
410 for (; adj !=
this && adj != adjAfter; adj = adj->
cyclicSucc());
411 result = adj ==
this;
417 template<
class EDGELIST>
420 for(
adjEntry adj : this->adjEntries) {
421 edge e = adj->theEdge();
422 if (adj == e->
adjTarget()) edgeList.pushBack(e);
426 template<
class EDGELIST>
429 for(
adjEntry adj : this->adjEntries) {
430 edge e = adj->theEdge();
431 if (adj == e->
adjSource()) edgeList.pushBack(e);
444 template<
typename CONTAINER>
inline void getAllNodes(
const Graph& G, CONTAINER& nodes);
445 template<
typename CONTAINER>
inline void getAllEdges(
const Graph& G, CONTAINER& edges);
508 #ifndef OGDF_MEMORY_POOL_NTS 548 generalizationMerger = 2,
549 generalizationExpander = 3,
550 highDegreeExpander = 4,
551 lowDegreeExpander = 5,
634 node chooseNode(std::function<
bool(
node)> includeNode = [](
node) {
return true; },
bool isFastTest =
true)
const;
643 edge chooseEdge(std::function<
bool(
edge)> includeEdge = [](
edge) {
return true; },
bool isFastTest =
true)
const;
650 template<
class CONTAINER>
652 internal::getAllNodes<CONTAINER>(*
this, nodeContainer);
660 template<
class CONTAINER>
662 internal::getAllEdges<CONTAINER>(*
this, edgeContainer);
684 node newNode(
int index);
758 virtual void delNode(
node v);
761 virtual void delEdge(
edge e);
764 virtual void clear();
800 m_it = m_graph->m_hiddenEdgeSets.pushFront(
this);
810 m_graph->m_hiddenEdgeSets.del(m_it);
828 void restore(
edge e);
868 void insert(
const Graph &G);
893 void unsplit(
node u);
907 virtual void unsplit(
edge eIn,
edge eOut);
1004 edge searchEdge (
node v,
node w,
bool directed =
false)
const;
1007 void reverseEdge(
edge e);
1010 void reverseAllEdges();
1019 template<
class NODELIST>
1021 node v = nodesToCollapse.popFrontRet();
1022 while (!nodesToCollapse.empty())
1024 node w = nodesToCollapse.popFrontRet();
1026 while (adj !=
nullptr)
1032 else if (e->
source() == w)
1050 template<
class ADJ_ENTRY_LIST>
1053 std::set<int> entries;
1057 entries.insert(adj->index());
1090 adjList.move(adjMove, adjList, adjPos, dir);
1124 void reverseAdjEdges();
1165 return genus() == 0;
1169 void consistencyCheck()
const;
1250 template<
class ArrayBase>
1252 #ifndef OGDF_MEMORY_POOL_NTS 1253 std::lock_guard<std::mutex> guard(m_mutexRegArrays);
1284 void resetEdgeIdCount(
int maxId);
1343 int stopNode (
int cc)
const {
return m_startNode[cc+1]; }
1349 int stopEdge (
int cc)
const {
return m_startEdge[cc+1]; }
1352 node v(
int i)
const {
return m_nodes[i]; }
1355 edge e(
int i)
const {
return m_edges[i]; }
1368 void constructInitByNodes(
1374 void constructInitByActiveNodes(
1381 void constructInitByCC(
1401 void resetTableSizes();
1405 void reinitArrays(
bool doResetTableSizes =
true);
1406 void reinitStructures();
1407 void resetAdjEntryIndex(
int newIndex,
int oldIndex);
1412 void restoreAllEdges();
1431 namespace internal {
1433 template<
typename CONTAINER>
1450 template<
typename CONTAINER>
node target() const
Returns the target node of the edge.
void adjEdges(EDGELIST &edgeList) const
Returns a list with all edges incident to this node.
void getAllEdges(const Graph &G, Array< edge > &edges)
int m_nodeIdCount
The Index that will be assigned to the next created node.
void moveAdjBefore(adjEntry adjMove, adjEntry adjBefore)
Moves adjacency entry adjMove before adjBefore.
bool isSource() const
Returns true iff this is the source adjacency entry of the corresponding edge.
Abstract base class for node arrays.
node m_tgt
The target node of the edge.
EdgeElement * edge
The type of edges.
Array< int > m_startEdge
start edge of each connected component in m_edges.
Functionality for temporarily hiding edges in constant time.
int numberOfEdges(int cc) const
Returns the number of edges in connected component cc.
adjEntry pred() const
Returns the predecessor in the adjacency list.
HiddenEdgeSet(Graph &graph)
Creates a new set of hidden edges.
node pred() const
Returns the predecessor in the list of all nodes.
edge theEdge() const
Returns the edge associated with this adjacency entry.
Data type for general directed graphs (adjacency list representation).
edge m_edge
The associated edge.
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
static int compare(const AdjElement &x, const AdjElement &y)
Standard Comparer.
adjEntry adjSource() const
Returns the corresponding adjacancy entry at source node.
AdjElement(node v)
Constructs an adjacency element for a given node.
void sort(node v, const ADJ_ENTRY_LIST &newOrder)
Sorts the adjacency list of node v according to newOrder.
void moveAdj(adjEntry adjMove, Direction dir, adjEntry adjPos)
Moves adjacency entry adjMove before or after adjPos.
void init()
Reinitializes the array to an array with empty index set.
#define OGDF_MALLOC_NEW_DELETE
Makes the class use malloc for memory allocation.
ListIterator< HiddenEdgeSet * > m_it
edge e(int i) const
Returns the edge with index i.
int degree() const
Returns the degree of the node (indegree + outdegree).
int stopNode(int cc) const
Returns the index of (one past) the last node in connected component cc.
int maxAdjEntryIndex() const
Returns the largest used adjEntry index.
int startEdge(int cc) const
Returns the index of the first edge in connected component cc.
#define OGDF_AUGMENT_STATICCOMPARER(type)
Add this macro to your class to turn it into a full static comparer.
int indeg() const
Returns the indegree of the node.
int outdeg() const
Returns the outdegree of the node.
adjEntry faceCyclePred() const
Returns the cyclic predecessor in face.
node firstNode() const
Returns the first node in the list of all nodes.
void outEdges(EDGELIST &edgeList) const
Returns a list with all outgoing edges of this node.
int numberOfCCs() const
Returns the number of connected components.
int index() const
Returns the index of the edge.
Dynamic arrays indexed with adjacency entries.
Array< int > m_startNode
start node of each connected component in m_nodes.
node v(int i) const
Returns the node with index i.
Dynamic arrays indexed with edges.
node succ() const
Returns the successor in the list of all nodes.
bool isParallelUndirected(edge e) const
Returns true iff edge e is parallel to this (undirected) edge (or if it is the same edge) ...
bool representsCombEmbedding() const
Returns true iff the graph represents a combinatorial embedding.
Decralation of graph iterators.
Array< edge > m_edges
array of all edges.
adjEntry cyclicSucc() const
Returns the cyclic successor in the adjacency list.
GraphObject * tail() const
Returns the last element in the list.
edge lastEdge() const
Returns the last edge in the list of all edges.
CCsInfo()
Creates a info structure associated with no graph.
Decralation of GraphElement and GraphList classes.
void moveRegisterArray(ListIterator< ArrayBase *> it, ArrayBase *pArray) const
Move the registration it of an graph element array to pArray (used with move semantics for graph elem...
adjEntry faceCycleSucc() const
Returns the cyclic successor in face.
int m_edgeIdCount
The Index that will be assigned to the next created edge.
int size() const
Returns the number of elements in the container.
void moveAdjAfter(adjEntry adjMove, adjEntry adjAfter)
Moves adjacency entry adjMove after adjAfter.
internal::GraphObjectContainer< EdgeElement > edges
The container containing all edge objects.
int adjEntryArrayTableSize() const
Returns the table size of adjEntry arrays associated with this graph.
const Graph & constGraph() const
Returns the associated graph.
int numberOfEdges() const
Returns the number of edges in the graph.
int m_edgeArrayTableSize
The current table size of edge arrays associated with this graph.
Dynamic arrays indexed with nodes.
int m_id
The (unique) index of the adjacency entry.
void inEdges(EDGELIST &edgeList) const
Returns a list with all incoming edges of this node.
EdgeElement(node src, node tgt, int id)
Constructs an edge element (src,tgt).
void collapse(NODELIST &nodesToCollapse)
Collapses all nodes in the list nodesToCollapse to the first node in the list.
int edgeArrayTableSize() const
Returns the table size of edge arrays associated with this graph.
edge firstEdge() const
Returns the first edge in the list of all edges.
static void copy(const T &from, T &to)
bool isBetween(adjEntry adjBefore, adjEntry adjAfter) const
Returns whether this adjacency entry lies between adjBefore and adjAfter in clockwise rotation...
EdgeType
The type of edges (only used in derived classes).
GraphObject * head() const
Returns the first element in the list.
Bucket function using the index of an edge's source node as bucket.
internal::GraphList< EdgeElement > m_edges
Abstract base class for adjacency entry arrays.
ListPure< EdgeArrayBase * > m_regEdgeArrays
The registered edge arrays.
AdjElement * m_adjSrc
Corresponding adjacancy entry at source node.
ListPure< AdjEntryArrayBase * > m_regAdjArrays
The registered adjEntry arrays.
Doubly linked lists (maintaining the length of the list).
ListPure< GraphObserver * > m_regStructures
The registered graph structures.
bool isInvertedDirected(edge e) const
Returns true iff edge e is an inverted edge to this (directed) edge.
static int compare(const EdgeElement &x, const EdgeElement &y)
Standard Comparer.
Bucket function using the index of an edge's target node as bucket.
node twinNode() const
Returns the associated node of the corresponding adjacency entry (shorthand for twin()->theNode()).
Class for the representation of edges.
adjEntry twin() const
Returns the corresponding adjacency element associated with the same edge.
int m_numCC
the number of connected components.
Base class for GraphElement lists.
void allAdjEntries(ADJLIST &adjList) const
Returns a list with all adjacency entries of this node.
NodeElement * node
The type of nodes.
int m_indeg
The indegree of the node.
The base class for objects used by (hyper)graphs.
bool isAdjacent(edge e) const
Returns true iff e is adjacent to the edge.
AdjElement(edge e, int id)
Constructs an adjacency entry for a given edge and index.
adjEntry lastAdj() const
Returns the last entry in the adjacency list.
Class for the representation of nodes.
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 ...
Encapsulates a pointer to a list element.
node lastNode() const
Returns the last node in the list of all nodes.
node opposite(node v) const
Returns the adjacent node different from v.
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...
ListPure< NodeArrayBase * > m_regNodeArrays
The registered node arrays.
#define OGDF_NEW_DELETE
Makes the class use OGDF's memory allocator.
adjEntry counterClockwiseFacePred() const
Returns the counter-clockwise predecessor in face.
AdjElement * m_twin
The corresponding adjacency entry (same edge)
adjEntry clockwiseFacePred() const
Returns the clockwise predecessor in face. Use faceCycleSucc instead!
const T & move(const T &v)
int getBucket(const edge &e) override
Returns target index of e.
std::mutex m_mutexRegArrays
The critical section for protecting shared acces to register/unregister methods.
bool empty() const
Returns true iff the list is empty.
int getBucket(const edge &e) override
Returns source index of e.
Info structure for maintaining connected components.
adjEntry cyclicPred() const
Returns the cyclic predecessor in the adjacency list.
const Graph * m_graph
points to the associated graph.
Abstract base class for bucket functions.
Array< node > m_nodes
array of all nodes.
EdgeElement(node src, node tgt, AdjElement *adjSrc, AdjElement *adjTgt, int id)
Constructs an edge element (src,tgt).
~HiddenEdgeSet()
Restores all hidden edges.
edge pred() const
Returns the predecessor in the list of all edges.
adjEntry counterClockwiseFaceSucc() const
Returns the counter-clockwise successor in face.
bool isSelfLoop() const
Returns true iff the edge is a self-loop (source node = target node).
int m_outdeg
The outdegree of the node.
int index() const
Returns the (unique) node index.
edge succ() const
Returns the successor in the list of all edges.
bool isIncident(node v) const
Returns true iff v is incident to the edge.
adjEntry succ() const
Returns the successor in the adjacency list.
void swapAdjEdges(adjEntry adj1, adjEntry adj2)
Exchanges two entries in an adjacency list.
bool isParallelDirected(edge e) const
Returns true iff edge e is parallel to this (directed) edge (or if it is the same edge) ...
int nodeArrayTableSize() const
Returns the table size of node arrays associated with this graph.
void reverseAdjEdges(node v)
Reverses the adjacency list of v.
NodeElement(int id)
Constructs a node element with index id.
int stopEdge(int cc) const
Returns the index of (one past) the last edge in connected component cc.
void allNodes(CONTAINER &nodeContainer) const
Returns a container with all nodes of the graph.
int maxNodeIndex() const
Returns the largest used node index.
void getAllNodes(const Graph &G, Array< node > &nodes)
node source() const
Returns the source node of the edge.
Abstract base class for edge arrays.
int numberOfNodes(int cc) const
Returns the number of nodes in connected component cc.
The namespace for all OGDF objects.
int maxEdgeIndex() const
Returns the largest used edge index.
node m_node
The node whose adjacency list contains this entry.
void allEdges(CONTAINER &edgeContainer) const
Returns a container with all edges of the graph.
int startNode(int cc) const
Returns the index of the first node in connected component cc.
NodePair(node src, node tgt)
Lists of graph objects (like nodes, edges, etc.).
NodeType
The type of nodes.
AdjElement * m_adjTgt
Corresponding adjacancy entry at target node.
int numberOfNodes() const
Returns the number of nodes in the graph.
int index() const
Returns the index of this adjacency element.
internal::GraphObjectContainer< NodeElement > nodes
The container containing all node objects.
adjEntry firstAdj() const
Returns the first entry in the adjaceny list.
int m_nodeArrayTableSize
The current table size of node arrays associated with this graph.
node commonNode(edge e) const
Returns the common node of the edge and e. Returns nullptr if the two edges are not adjacent...
int m_id
The (unique) index of the node.
adjEntry adjTarget() const
Returns the corresponding adjacancy entry at target node.
List< HiddenEdgeSet * > m_hiddenEdgeSets
The list of hidden edges.
node m_src
The source node of the edge.
bool empty() const
Returns true iff the graph is empty, i.e., contains no nodes.
node theNode() const
Returns the node whose adjacency list contains this element.
Class for adjacency list elements.
std::ostream & operator<<(std::ostream &os, const ogdf::Array< E, INDEX > &a)
Prints array a to output stream os.
Abstract Base class for graph observers.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
static int compare(const NodeElement &x, const NodeElement &y)
Standard Comparer.
adjEntry clockwiseFaceSucc() const
Returns the clockwise successor in face. Use faceCycleSucc instead!
internal::GraphObjectContainer< AdjElement > adjEntries
The container containing all entries in the adjacency list of this node.