100 operator edge()
const {
return m_edge; }
106 operator node()
const {
return m_node; }
118 bool isSource()
const;
166 const Graph* graphOf()
const;
188 const Graph* m_pGraph;
200 : m_indeg(0), m_outdeg(0), m_id(id), m_pGraph(pGraph) { }
214 int indeg()
const {
return m_indeg; }
220 int degree()
const {
return m_indeg + m_outdeg; }
239 template<
class ADJLIST>
242 for (
adjEntry adj : this->adjEntries) {
255 template<
class EDGELIST>
258 for (
adjEntry adj : this->adjEntries) {
259 edgeList.pushBack(adj->theEdge());
268 template<
class EDGELIST>
269 void inEdges(
EDGELIST& edgeList)
const;
276 template<
class EDGELIST>
277 void outEdges(
EDGELIST& edgeList)
const;
281 const Graph* graphOf()
const {
return m_pGraph; }
319 : m_src(src), m_tgt(
tgt), m_adjSrc(
adjSrc), m_adjTgt(
adjTgt), m_id(id) { }
341 std::array<node, 2>
nodes()
const {
return std::array<node, 2> {{m_src, m_tgt}}; }
352 return v == m_src ? m_tgt : m_src;
366 return isParallelDirected(e) || isInvertedDirected(e);
377 const Graph* graphOf()
const {
return m_src->graphOf(); }
388 return (m_src == e->
m_src || m_src == e->
m_tgt)
390 : ((m_tgt == e->
m_src || m_tgt == e->
m_tgt) ? m_tgt :
nullptr);
397 return v == m_src ? m_adjSrc : m_adjTgt;
413inline const Graph* AdjElement::graphOf()
const {
return m_node->graphOf(); }
431 result = adj ==
this;
437template<
class EDGELIST>
441 edge e = adj->theEdge();
443 edgeList.pushBack(e);
448template<
class EDGELIST>
452 edge e = adj->theEdge();
454 edgeList.pushBack(e);
471template<
typename CONTAINER>
473template<
typename CONTAINER>
537#ifndef OGDF_MEMORY_POOL_NTS
566 enum class EdgeType { association = 0, generalization = 1, dependency = 2 };
572 generalizationMerger = 2,
573 generalizationExpander = 3,
574 highDegreeExpander = 4,
575 lowDegreeExpander = 5,
684 template<
class CONTAINER>
694 template<
class CONTAINER>
832 m_it = m_graph->m_hiddenEdgeSets.pushFront(
this);
841 m_graph->m_hiddenEdgeSets.del(m_it);
1055 template<
class NODELIST>
1061 while (adj !=
nullptr) {
1066 }
else if (e->
source() == w) {
1085 template<
class ADJ_ENTRY_LIST>
1088 std::set<int> entries;
1092 entries.insert(adj->index());
1280 template<
class ArrayBase>
1282#ifndef OGDF_MEMORY_POOL_NTS
1283 std::lock_guard<std::mutex>
guard(m_mutexRegArrays);
1380 node v(
int i)
const {
return m_nodes[i]; }
1383 edge e(
int i)
const {
return m_edges[i]; }
1450template<
typename CONTAINER>
1453 for (
node v : G.nodes) {
1460 nodes.
init(G.numberOfNodes());
1462 for (
node v : G.nodes) {
1467template<
typename CONTAINER>
1470 for (
edge v : G.edges) {
1477 edges.
init(G.numberOfEdges());
1479 for (
edge v : G.edges) {
1495 os <<
"(" <<
np.source <<
"," <<
np.target <<
")";
Decralation of GraphElement and GraphList classes.
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.
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.
Abstract base class for adjacency entry arrays.
Dynamic arrays indexed with adjacency entries.
The parameterized class Array implements dynamic arrays of type E.
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.
Abstract base class for edge arrays.
Dynamic arrays indexed with edges.
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.
AdjElement * m_adjSrc
Corresponding adjacancy 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 adjacancy 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.
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.
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.
void hide(edge e)
Hides the given edge.
~HiddenEdgeSet()
Restores all hidden edges.
HiddenEdgeSet & operator=(const HiddenEdgeSet &)
void restore(edge e)
Reveals the given edge.
ListIterator< HiddenEdgeSet * > m_it
HiddenEdgeSet(const HiddenEdgeSet &)
HiddenEdgeSet(Graph &graph)
Creates a new set of hidden edges.
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.
Data type for general directed graphs (adjacency list representation).
ListIterator< AdjEntryArrayBase * > registerArray(AdjEntryArrayBase *pAdjArray) const
Registers an adjEntry array.
void construct(const Graph &G, NodeArray< node > &mapNode, EdgeArray< edge > &mapEdge)
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.
ListIterator< NodeArrayBase * > registerArray(NodeArrayBase *pNodeArray) const
Registers a node array.
node newNode(int index)
Creates a new node with predefined index and returns it.
virtual void unsplit(edge eIn, edge eOut)
Undoes a split operation.
int adjEntryArrayTableSize() const
Returns the table size of adjEntry arrays associated with this graph.
void unsplit(node u)
Undoes a split operation.
void constructInitByCC(const CCsInfo &info, int cc, NodeArray< node > &mapNode, EdgeArray< edge > &mapEdge)
Constructs a copy of connected component cc in info.
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.
ListPure< EdgeArrayBase * > m_regEdgeArrays
The registered edge arrays.
node lastNode() const
Returns the last node in the list of all nodes.
edge newEdge(node v, adjEntry adjTgt)
Creates a new edge at predefined positions in the adjacency lists.
int numberOfNodes() const
Returns the number of nodes in the graph.
ListPure< GraphObserver * > m_regStructures
The registered graph structures.
ListPure< AdjEntryArrayBase * > m_regAdjArrays
The registered adjEntry arrays.
void moveSource(edge e, node w)
Moves the source node of edge e to node w.
int m_nodeArrayTableSize
The current table size of node arrays associated with this graph.
edge createEdgeElement(node v, node w, adjEntry adjSrc, adjEntry adjTgt)
void sort(node v, const ADJ_ENTRY_LIST &newOrder)
Sorts the adjacency list of node v according to newOrder.
void reinitArrays(bool doResetTableSizes=true)
Re-initializes registed arrays with respect to the current sizes. Calls resetTableSizes() if doResetT...
edge lastEdge() const
Returns the last edge in the list of all edges.
void resetAdjEntryIndex(int newIndex, int oldIndex)
ListIterator< EdgeArrayBase * > registerArray(EdgeArrayBase *pEdgeArray) const
Registers an edge array.
void unregisterArray(ListIterator< AdjEntryArrayBase * > it) const
Unregisters an adjEntry array.
edge firstEdge() const
Returns the first edge in the list of all edges.
edge newEdge(node v, node w)
Creates a new edge (v,w) and returns it.
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.
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 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...
int nodeArrayTableSize() const
Returns the table size of node arrays associated with this graph.
int edgeArrayTableSize() const
Returns the table size of edge arrays associated with this graph.
void reverseEdge(edge e)
Reverses the edge e, i.e., exchanges source and target node.
edge newEdge(adjEntry adjSrc, node w)
Creates a new edge at predefined positions in the adjacency lists.
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.
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.
void constructInitByNodes(const Graph &G, const List< node > &nodeList, NodeArray< node > &mapNode, EdgeArray< edge > &mapEdge)
Constructs a copy of the subgraph of G induced by nodeList.
List< HiddenEdgeSet * > m_hiddenEdgeSets
The list of hidden edges.
edge newEdge(adjEntry adjSrc, adjEntry adjTgt, Direction dir=Direction::after)
Creates a new edge at predefined positions in the adjacency lists.
std::mutex m_mutexRegArrays
The critical section for protecting shared acces to register/unregister methods.
void insert(const Graph &G)
Inserts Graph G as a subgraph into this Graph.
Graph(const Graph &G)
Constructs a graph that is a copy of G.
Graph & operator=(const Graph &G)
Assignment operator.
void reverseAdjEdges()
Reverses all adjacency lists.
void copy(const Graph &G, NodeArray< node > &mapNode, EdgeArray< edge > &mapEdge)
internal::GraphObjectContainer< NodeElement > nodes
The container containing all node objects.
void constructInitByActiveNodes(const List< node > &nodeList, const NodeArray< bool > &activeNodes, NodeArray< node > &mapNode, EdgeArray< edge > &mapEdge)
void moveTarget(edge e, adjEntry adjTgt, Direction dir)
Moves the target node of edge e to a specific position in an adjacency list.
ListIterator< GraphObserver * > registerStructure(GraphObserver *pStructure) const
Registers a graph observer (e.g. a ClusterGraph).
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.
edge chooseEdge(std::function< bool(edge)> includeEdge=[](edge) { return true;}, bool isFastTest=true) const
Returns a random edge.
void assign(const Graph &G, NodeArray< node > &mapNode, EdgeArray< edge > &mapEdge)
void moveAdj(adjEntry adjMove, Direction dir, adjEntry adjPos)
Moves adjacency entry adjMove before or after adjPos.
node firstNode() const
Returns the first node in the list of all nodes.
Graph()
Constructs an empty graph.
void reverseAdjEdges(node v)
Reverses the adjacency list of v.
void unregisterArray(ListIterator< NodeArrayBase * > it) const
Unregisters a node array.
ListPure< NodeArrayBase * > m_regNodeArrays
The registered node arrays.
NodeType
The type of nodes.
virtual edge split(edge e)
Splits edge e into two edges introducing a new node.
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).
void copy(const Graph &G)
virtual ~Graph()
Destructor.
void restoreAllEdges()
Used to restore all hidden edges upon deleting the graph.
void unregisterStructure(ListIterator< GraphObserver * > it) const
Unregisters a graph observer.
node newNode()
Creates a new node and returns it.
edge newEdge(node v, node w, int index)
Creates a new edge (v,w) with predefined index and returns it.
void insert(const Graph &G, NodeArray< node > &nodeMap)
Inserts Graph G as a subgraph into this Graph.
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)
internal::GraphObjectContainer< EdgeElement > edges
The container containing all edge objects.
int genus() const
Returns the genus of the graph's embedding.
int m_edgeArrayTableSize
The current table size of edge arrays associated with this graph.
void unregisterArray(ListIterator< EdgeArrayBase * > it) const
Unregisters an edge array.
void resetTableSizes()
Sets the sizes of registered node and edge arrays to the next power of two that is no less than the c...
Abstract Base class for graph observers.
Doubly linked lists (maintaining the length of the list).
Encapsulates a pointer to a list element.
Abstract base class for node arrays.
Dynamic arrays indexed with nodes.
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(int id)
Constructs a node element with index id.
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.
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.
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.
bool empty() const
Returns true iff the list is empty.
T * tail() const
Returns the last element in the list.
int size() const
Returns the size of the list.
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Decralation of graph iterators.
#define OGDF_AUGMENT_STATICCOMPARER(type)
Add this macro to your class to turn it into a full static comparer.
#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.
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
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.
NodePair(node src, node tgt)