Data type for general directed graphs (adjacency list representation). More...
#include <ogdf/basic/Graph_d.h>
Classes | |
class | CCsInfo |
Info structure for maintaining connected components. More... | |
class | HiddenEdgeSet |
Functionality for temporarily hiding edges in constant time. More... | |
Public Types | |
Enumerations | |
These enumerations are mainly meant for advanced or internal usage scenarios. | |
enum | EdgeType { EdgeType::association = 0, EdgeType::generalization = 1, EdgeType::dependency = 2 } |
The type of edges (only used in derived classes). More... | |
enum | NodeType { NodeType::vertex = 0, NodeType::dummy = 1, NodeType::generalizationMerger = 2, NodeType::generalizationExpander = 3, NodeType::highDegreeExpander = 4, NodeType::lowDegreeExpander = 5, NodeType::associationClass = 6 } |
The type of nodes. More... | |
Iterators | |
These types are used for graph object iterators, which are returned by graph object containers like nodes and edges. | |
using | node_iterator = internal::GraphIterator< node > |
Provides a bidirectional iterator to a node in a graph. More... | |
using | edge_iterator = internal::GraphIterator< edge > |
Provides a bidirectional iterator to an edge in a graph. More... | |
using | adjEntry_iterator = internal::GraphIterator< adjEntry > |
Provides a bidirectional iterator to an entry in an adjacency list. More... | |
Public Member Functions | |
Graph () | |
Constructs an empty graph. More... | |
Graph (const Graph ©) | |
Constructs a graph that is a copy of G . More... | |
Graph (Graph &&move)=delete | |
virtual | ~Graph () |
Destructor. More... | |
Graph & | operator= (const Graph ©) |
Overwrites this graph to be a copy of G . More... | |
Graph & | operator= (Graph &&move)=delete |
Access methods | |
bool | empty () const |
Returns true iff the graph is empty, i.e., contains no nodes. More... | |
int | numberOfNodes () const |
Returns the number of nodes in the graph. More... | |
int | numberOfEdges () const |
Returns the number of edges in the graph. More... | |
int | maxNodeIndex () const |
Returns the largest used node index. More... | |
int | maxEdgeIndex () const |
Returns the largest used edge index. More... | |
int | maxAdjEntryIndex () const |
Returns the largest used adjEntry index. More... | |
node | firstNode () const |
Returns the first node in the list of all nodes. More... | |
node | lastNode () const |
Returns the last node in the list of all nodes. More... | |
edge | firstEdge () const |
Returns the first edge in the list of all edges. More... | |
edge | lastEdge () const |
Returns the last edge in the list of all edges. More... | |
node | chooseNode (std::function< bool(node)> includeNode=[](node) { return true;}, bool isFastTest=true) const |
Returns a random node. More... | |
edge | chooseEdge (std::function< bool(edge)> includeEdge=[](edge) { return true;}, bool isFastTest=true) const |
Returns a random edge. More... | |
template<class CONTAINER > | |
void | allNodes (CONTAINER &nodeContainer) const |
Returns a container with all nodes of the graph. More... | |
template<class CONTAINER > | |
void | allEdges (CONTAINER &edgeContainer) const |
Returns a container with all edges of the graph. More... | |
Creation of new nodes and edges | |
node | newNode (int index=-1) |
Creates a new node and returns it. More... | |
edge | newEdge (node v, node w, int index=-1) |
Creates a new edge (v ,w ) and returns it. More... | |
edge | newEdge (node v, adjEntry adjTgt, int index=-1) |
Creates a new edge at predefined positions in the adjacency lists. More... | |
edge | newEdge (adjEntry adjSrc, node w, int index=-1) |
Creates a new edge at predefined positions in the adjacency lists. More... | |
edge | newEdge (adjEntry adjSrc, adjEntry adjTgt, Direction dir=Direction::after, int index=-1) |
Creates a new edge at predefined positions in the adjacency lists. More... | |
template<typename S , typename T > | |
edge | newEdge (S src, Direction dirSrc, T tgt, Direction dirTgt, int index=-1) |
Creates a new edge at predefined positions in the adjacency lists. More... | |
Removing nodes and edges | |
virtual void | delNode (node v) |
Removes node v and all incident edges from the graph. More... | |
virtual void | delEdge (edge e) |
Removes edge e from the graph. More... | |
virtual void | clear () |
Removes all nodes and all edges from the graph. More... | |
void | restoreAllEdges () |
Restore all hidden edges and invalidate all HiddenEdgeSets. More... | |
Advanced modification methods | |
virtual edge | split (edge e) |
Splits edge e into two edges introducing a new node. More... | |
void | unsplit (node u) |
Undoes a split operation. More... | |
virtual void | unsplit (edge eIn, edge eOut) |
Undoes a split operation. More... | |
node | splitNode (adjEntry adjStartLeft, adjEntry adjStartRight) |
Splits a node while preserving the order of adjacency entries. More... | |
node | contract (edge e, bool keepSelfLoops=false) |
Contracts edge e while preserving the order of adjacency entries. More... | |
void | move (edge e, adjEntry adjSrc, Direction dirSrc, adjEntry adjTgt, Direction dirTgt) |
Moves edge e to a different adjacency list. More... | |
void | moveTarget (edge e, node w) |
Moves the target node of edge e to node w . More... | |
void | moveTarget (edge e, adjEntry adjTgt, Direction dir) |
Moves the target node of edge e to a specific position in an adjacency list. More... | |
void | moveSource (edge e, node w) |
Moves the source node of edge e to node w . More... | |
void | moveSource (edge e, adjEntry adjSrc, Direction dir) |
Moves the source node of edge e to a specific position in an adjacency list. More... | |
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 ))). More... | |
void | reverseEdge (edge e) |
Reverses the edge e , i.e., exchanges source and target node. More... | |
void | reverseAllEdges () |
Reverses all edges in the graph. More... | |
template<class NODELIST > | |
void | collapse (NODELIST &nodesToCollapse) |
Collapses all nodes in the list nodesToCollapse to the first node in the list. More... | |
template<class ADJ_ENTRY_LIST > | |
void | sort (node v, const ADJ_ENTRY_LIST &newOrder) |
Sorts the adjacency list of node v according to newOrder . More... | |
template<class IT > | |
void | sort (node v, IT begin, IT end) |
Sorts the adjacency list of node v according to the range denoted by two iterators. More... | |
void | reverseAdjEdges (node v) |
Reverses the adjacency list of v . More... | |
void | moveAdj (adjEntry adjMove, Direction dir, adjEntry adjPos) |
Moves adjacency entry adjMove before or after adjPos . More... | |
void | moveAdjAfter (adjEntry adjMove, adjEntry adjAfter) |
Moves adjacency entry adjMove after adjAfter . More... | |
void | moveAdjBefore (adjEntry adjMove, adjEntry adjBefore) |
Moves adjacency entry adjMove before adjBefore . More... | |
void | reverseAdjEdges () |
Reverses all adjacency lists. More... | |
void | swapAdjEdges (adjEntry adj1, adjEntry adj2) |
Exchanges two entries in an adjacency list. More... | |
Miscellaneous | |
int | genus () const |
Returns the genus of the graph's embedding. More... | |
bool | representsCombEmbedding () const |
Returns true iff the graph represents a combinatorial embedding. More... | |
void | consistencyCheck () const |
Asserts that this graph is consistent. More... | |
Registering arrays and observers | |
These methods are used by various graph array types like NodeArray or EdgeArray. There should be no need to use them directly in user code. | |
internal::GraphNodeRegistry & | nodeRegistry () |
Returns a reference to the registry of node arrays associated with this graph. More... | |
const internal::GraphNodeRegistry & | nodeRegistry () const |
Returns a const reference to the registry of node arrays associated with this graph. More... | |
operator const internal::GraphNodeRegistry & () const | |
internal::GraphEdgeRegistry & | edgeRegistry () |
Returns a reference to the registry of edge arrays associated with this graph. More... | |
const internal::GraphEdgeRegistry & | edgeRegistry () const |
Returns a const reference to the registry of edge arrays associated with this graph. More... | |
operator const internal::GraphEdgeRegistry & () const | |
internal::GraphAdjRegistry & | adjEntryRegistry () |
Returns a reference to the registry of adjEntry arrays associated with this graph. More... | |
const internal::GraphAdjRegistry & | adjEntryRegistry () const |
Returns a const reference to the registry of adjEntry arrays associated with this graph. More... | |
operator const internal::GraphAdjRegistry & () const | |
void | resetEdgeIdCount (int maxId) |
Resets the edge id count to maxId . More... | |
void | resetNodeIdCount (int maxId) |
Public Member Functions inherited from ogdf::Observable< GraphObserver, Graph > | |
Observable ()=default | |
Observable (const Observable ©)=delete | |
If you want to copy a subclass of Observable, call the default Observable() constructor. More... | |
Observable (Observable &&move)=delete | |
If you want to move a subclass of Observable, call the default Observable() constructor. More... | |
virtual | ~Observable () |
Observable & | operator= (const Observable ©)=delete |
Observable & | operator= (Observable &&move)=delete |
Public Attributes | |
Graph object containers | |
These containers maintain the nodes and edges of the graph, and provide node and edge iterators. | |
internal::GraphObjectContainer< NodeElement > | nodes |
The container containing all node objects. More... | |
internal::GraphObjectContainer< EdgeElement > | edges |
The container containing all edge objects. More... | |
Private Member Functions | |
void | moveAdj (adjEntry adj, node w) |
moves adjacency entry to node w More... | |
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 edges. More... | |
node | pureNewNode (int index) |
Creates a new node object with id index and adds it to the list of nodes. More... | |
Static Private Member Functions | |
static void | insertAdjEntry (adjEntry oldAdj, adjEntry newAdj, Direction dir) |
static void | insertAdjEntry (node n, adjEntry newAdj, Direction dir) |
Private Attributes | |
int | m_edgeIdCount |
The Index that will be assigned to the next created edge. More... | |
List< HiddenEdgeSet * > | m_hiddenEdgeSets |
The list of hidden edges. More... | |
int | m_nodeIdCount |
The Index that will be assigned to the next created node. More... | |
internal::GraphAdjRegistry | m_regAdjArrays |
The registered adjEntry arrays. More... | |
internal::GraphEdgeRegistry | m_regEdgeArrays |
The registered edge arrays. More... | |
internal::GraphNodeRegistry | m_regNodeArrays |
The registered node arrays. More... | |
Friends | |
class | GraphObserver |
Subgraph insertion | |
template<OGDF_NODE_ITER NI, OGDF_EDGE_ITER EI, bool copyEmbedding = true, bool copyIDs = false, bool notifyObservers = true> | |
std::pair< int, int > | insert (const NI &nodesBegin, const NI &nodesEnd, const EI &edgesBegin, const EI &edgesEnd, NodeArray< node > &nodeMap, EdgeArray< edge > &edgeMap) |
Inserts a copy of a given subgraph into this graph. More... | |
template<OGDF_NODE_ITER NI, OGDF_EDGE_FILTER EF, bool copyIDs = false, bool notifyObservers = true> | |
std::pair< int, int > | insert (const NI &nodesBegin, const NI &nodesEnd, const EF &edgeFilter, NodeArray< node > &nodeMap, EdgeArray< edge > &edgeMap) |
Inserts a copy of a given subgraph into this graph. More... | |
template<OGDF_NODE_LIST NL> | |
std::pair< int, int > | insert (const NL &nodeList, const EdgeSet< true > &edgeSet, NodeArray< node > &nodeMap, EdgeArray< edge > &edgeMap) |
Inserts a copy of a given subgraph into this graph. More... | |
template<OGDF_NODE_LIST NL> | |
std::pair< int, int > | insert (const NL &nodeList, const EdgeSet< false > &edgeSet, NodeArray< node > &nodeMap, EdgeArray< edge > &edgeMap) |
Inserts a copy of a given subgraph into this graph. More... | |
template<OGDF_NODE_LIST NL, OGDF_EDGE_LIST EL> | |
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. More... | |
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. More... | |
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. More... | |
std::pair< int, int > | insert (const Graph &G) |
Inserts a copy of a given Graph G into this graph. More... | |
template<OGDF_NODE_ITER NI, bool notifyObservers, bool copyIDs> | |
void | insertNodes (const NI &nodesBegin, const NI &nodesEnd, NodeArray< node, true > &nodeMap, int &newNodes, void *cbData) |
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. More... | |
virtual void | nodeInserted (void *userData, node original, node copy) |
Callback notifying subclasses that insert() copied a node. More... | |
virtual void | edgeInserted (void *userData, edge original, edge copy) |
Callback notifying subclasses that insert() copied an edge. More... | |
virtual void | postInsert (void *userData, int newNodes, int newEdges) |
Callback notifying subclasses that an insert() call has finished. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from ogdf::Observable< GraphObserver, Graph > | |
void | clearObservers () |
const ListPure< GraphObserver * > & | getObservers () const |
Data type for general directed graphs (adjacency list representation).
In embedded graphs, adjacency lists are given in clockwise order.
The class Graph allows shared access of threads to const methods only. If one thread executes a non-const method, shared access is no longer thread-safe.
You may iterate over the nodes and edges of a graph using C++11 range-based for loops. Find some examples below.
Iterate over all nodes v of graph G using c++11 syntax :
Iterate over all nodes v of graph G :
Iterate over all edges e of graph G using c++11 syntax :
|
strong |
|
strong |
ogdf::Graph::Graph | ( | ) |
Constructs an empty graph.
ogdf::Graph::Graph | ( | const Graph & | copy | ) |
Constructs a graph that is a copy of G
.
The constructor assures that the adjacency lists of nodes in the constructed graph are in the same order as the adjacency lists in G
. This is in particular important when dealing with embedded graphs.
copy | is the graph that will be copied. |
|
delete |
|
virtual |
Destructor.
|
inline |
|
inline |
|
inline |
|
inline |
|
virtual |
Removes all nodes and all edges from the graph.
Reimplemented in ogdf::GraphCopyBase, ogdf::GraphCopy, ogdf::GraphCopySimple, ogdf::OverlappingGraphCopy, and ogdf::TwoSAT.
|
inline |
Collapses all nodes in the list nodesToCollapse
to the first node in the list.
Parallel edges are removed.
NODELIST | is the type of input node list. |
nodesToCollapse | is the list of nodes that will be collapsed. This list will be empty after the call. |
void ogdf::Graph::consistencyCheck | ( | ) | const |
Asserts that this graph is consistent.
Contracts edge e
while preserving the order of adjacency entries.
e | is the edge to be contracted. |
keepSelfLoops | determines whether edges parallel to e will result in self-loops or not (in the latter case, they will also be contracted). |
e
to which all edges have been moved. The implementation ensures this to be the source of the former edge e
.
|
virtual |
Removes edge e
from the graph.
Reimplemented in ogdf::GraphCopy, ogdf::GraphCopySimple, ogdf::PlanRepExpansion, and ogdf::OverlappingGraphCopy.
|
virtual |
Removes node v
and all incident edges from the graph.
Reimplemented in ogdf::GraphCopyBase, and ogdf::OverlappingGraphCopy.
|
inlineprotectedvirtual |
Callback notifying subclasses that insert() copied an edge.
userData | value returned from the initial preInsert() call |
original | the original edge |
copy | the created copy |
Reimplemented in ogdf::GraphCopy, and ogdf::GraphCopySimple.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
int ogdf::Graph::genus | ( | ) | const |
Returns the genus of the graph's embedding.
The genus of a graph is defined as follows. Let G be a graph with m edges, n nodes, nz isolated vertices, fc face cycles, and c connected components. Then,
\[ genus(G) = (m - n - nz - fc + 2c)/2 \]
|
inline |
std::pair< int, int > ogdf::Graph::insert | ( | const NI & | nodesBegin, |
const NI & | nodesEnd, | ||
const EF & | edgeFilter, | ||
NodeArray< node > & | nodeMap, | ||
EdgeArray< edge > & | edgeMap | ||
) |
Inserts a copy of a given subgraph into this graph.
Inserts copies of the nodes given by the iterator pair nodesBegin
... nodesEnd
into this Graph and, for each of these nodes, sets the corresponding value in nodeMap
to the newly created node. The same happens with all incident edges for which function edgeFilter
returns true
, although an edge is only inserted if both its endpoints were also inserted (i.e., the corresponding values in nodeMap
are non-null). This method always copies the embedding of the subgraph without an overhead.
NI | The iterator type used for nodesBegin ... nodesEnd . |
EF | The function type used for filtering edges, e.g. std::function<bool(edge)> . |
copyIDs | if explicitly set to true, the newly inserted nodes and edges will have the same IDs as their originals. The Graph datastructure will become corrupt if one of the IDs is already present in the graph. By default, new IDs are generated as by newNode() and newEdge(). |
notifyObservers | if explicitly set to false, no GraphObservers will be notified and (Node-,Edge-,AdjEntry-)Arrays won't grow. Only use if you know what you are doing! |
nodesBegin | Iterator to the first node to insert. |
nodesEnd | Iterator one past the last node to insert. |
edgeFilter | Function returning true for all edges that should be inserted. |
nodeMap | A NodeArray registered with the Graph of the nodes in nodesBegin ... nodesEnd . For each of these original nodes, this map will point to the newly-created copy after this call returns. Note that this map may only contain nullptr values, otherwise the result is undefined. |
edgeMap | An EdgeArray registered with the Graph of the edges in edgesBegin ... edgesEnd . For each of these original edges, this map will point to the newly-created copy after this call returns. Note that this map may only contain nullptr values, otherwise the result is undefined. |
Definition at line 214 of file InducedSubgraph.h.
std::pair< int, int > ogdf::Graph::insert | ( | const NI & | nodesBegin, |
const NI & | nodesEnd, | ||
const EI & | edgesBegin, | ||
const EI & | edgesEnd, | ||
NodeArray< node > & | nodeMap, | ||
EdgeArray< edge > & | edgeMap | ||
) |
Inserts a copy of a given subgraph into this graph.
Inserts copies of the nodes given by the iterator pair nodesBegin
... nodesEnd
into this Graph and, for each of these nodes, sets the corresponding value in nodeMap
to the newly created node. The same happens with the edges in edgesBegin
... edgesEnd
and new edges in edgeMap
, although an edge is only inserted if both its endpoints were also inserted (i.e., the corresponding values in nodeMap
are non-null).
NI | The iterator type used for nodesBegin ... nodesEnd . |
EI | The iterator type used for edgesBegin ... edgesEnd . |
copyEmbedding | if explicitly set to false, the inserted subgraph will have an arbitrary embedding. Otherwise, the embedding of the inserted subgraph will be copied from the original. |
copyIDs | if explicitly set to true, the newly inserted nodes and edges will have the same IDs as their originals. The Graph datastructure will become corrupt if one of the IDs is already present in the graph. By default, new IDs are generated as by newNode() and newEdge(). |
notifyObservers | if explicitly set to false, no GraphObservers will be notified and (Node-,Edge-,AdjEntry-)Arrays won't grow. Only use if you know what you are doing! |
nodesBegin | Iterator to the first node to insert. |
nodesEnd | Iterator one past the last node to insert. |
edgesBegin | Iterator to the first edge to insert (if its endpoints are also inserted). |
edgesEnd | Iterator one past the last edge to insert (if its endpoints are also inserted). |
nodeMap | A NodeArray registered with the Graph of the nodes in nodesBegin ... nodesEnd . After this call returns, for each of these original nodes, this map will point to the newly-created copy. Note that all (and only) edges in edgesBegin ... edgesEnd will be created if they have non-null endpoints after the call, which includes user-supplied non-null values present when the function is called. It is thus recommended to pass a map with only nullptrs. However, it is possible to use the same nodeMap for multiple calls of insert using edge iterators (which then of course will contain non-null values for the second call onwards). |
edgeMap | An EdgeArray registered with the Graph of the edges in edgesBegin ... edgesEnd . For each of these original edges, this map will point to the newly-created copy after this call returns. |
Definition at line 102 of file InducedSubgraph.h.
std::pair< int, int > ogdf::Graph::insert | ( | const NL & | nodeList, |
const EdgeSet< false > & | edgeSet, | ||
NodeArray< node > & | nodeMap, | ||
EdgeArray< edge > & | edgeMap | ||
) |
Inserts a copy of a given subgraph into this graph.
See the other insert() variants for details, this method is a short-cut for a container of nodes together with an EdgeSet<false> used for filtering edges.
Definition at line 162 of file GraphSets.h.
std::pair< int, int > ogdf::Graph::insert | ( | const NL & | nodeList, |
const EdgeSet< true > & | edgeSet, | ||
NodeArray< node > & | nodeMap, | ||
EdgeArray< edge > & | edgeMap | ||
) |
Inserts a copy of a given subgraph into this graph.
See the other insert() variants for details, this method is a short-cut for a container of nodes together with an EdgeSet<true> used for filtering edges.
Definition at line 150 of file GraphSets.h.
|
private |
Definition at line 76 of file InducedSubgraph.h.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
void ogdf::Graph::move | ( | edge | e, |
adjEntry | adjSrc, | ||
Direction | dirSrc, | ||
adjEntry | adjTgt, | ||
Direction | dirTgt | ||
) |
Moves edge e
to a different adjacency list.
The source adjacency entry of e
is moved to the adjacency list containing adjSrc
and is inserted before or after adjSrc
, and its target adjacency entry to the adjacency list containing adjTgt
and is inserted before or after adjTgt
; e
is afterwards an edge from owner(adjSrc
) to owner(adjTgt
).
e | is the edge to be moved. |
adjSrc | is the adjaceny entry before or after which the source adjacency entry of e will be inserted. |
dirSrc | specifies if the source adjacency entry of e will be inserted before or after adjSrc . |
adjTgt | is the adjaceny entry before or after which the target adjacency entry of e will be inserted. |
dirTgt | specifies if the target adjacency entry of e will be inserted before or after adjTgt . |
Moves adjacency entry adjMove
before or after adjPos
.
adjMove
and adjAfter are distinct entries in the same adjacency list.adjMove | is an entry in the adjacency list of a node in this graph. |
adjPos | is an entry in the same adjacency list as adjMove . |
dir | specifies if adjMove is moved before or after adjPos . |
Moves adjacency entry adjMove
after adjAfter
.
adjMove
and adjAfter
are distinct entries in the same adjacency list.adjMove | is an entry in the adjacency list of a node in this graph. |
adjAfter | is an entry in the same adjacency list as adjMove . |
Moves adjacency entry adjMove
before adjBefore
.
adjMove
and adjBefore
are distinct entries in the same adjacency list.adjMove | is an entry in the adjacency list of a node in this graph. |
adjBefore | is an entry in the same adjacency list as adjMove . |
Moves the source node of edge e
to a specific position in an adjacency list.
Let w be the node containing adjSrc
. If e=
(v,u) before, then e=(w,u) afterwards. Inserts the adjacency entry before or after adjSrc
according to dir
.
e | is the edge whose source node is moved. |
adjSrc | is the adjacency entry before or after which the source adjacency entry of e is inserted. |
dir | specifies if the source adjacency entry of e is inserted before or after adjSrc . |
Moves the source node of edge e
to node w
.
If e=
(v,u) before, then e=
(w
,u) afterwards.
e | is the edge whose source node is moved. |
w | is the new source node of e . |
Moves the target node of edge e
to a specific position in an adjacency list.
Let w be the node containing adjTgt
. If e=
(v,u) before, then e=(v,w) afterwards. Inserts the adjacency entry before or after adjTgt
according to dir
.
e | is the edge whose target node is moved. |
adjTgt | is the adjacency entry before or after which the target adjacency entry of e is inserted. |
dir | specifies if the target adjacency entry of e is inserted before or after adjTgt . |
Moves the target node of edge e
to node w
.
If e=
(v,u) before, then e=
(v,w
) afterwards.
e | is the edge whose target node is moved. |
w | is the new target node of e . |
|
inline |
Creates a new edge at predefined positions in the adjacency lists.
Let v be the node whose adjacency list contains adjSrc
, and w the node whose adjacency list contains adjTgt
. Then, the created edge is (v,w).
adjSrc | is the adjacency entry before / after which the new edge is inserted in the adjacency list of v. |
adjTgt | is the adjacency entry before / after which the new edge is inserted in the adjacency list of w. |
dir | specifies if the edge is inserted before or after the given adjacency entries. |
index | is the index that will be assigned to the newly created edge. If negative or not given will use the next free index maxEdgeIndex() . Passing an edge index that is already in use results in an inconsistent data structure. Only specify this parameter if you know what you're doing! |
Creates a new edge at predefined positions in the adjacency lists.
Let v be the node whose adjacency list contains adjSrc
. Then, the created edge is (v,w
).
adjSrc | is the adjacency entry after which the new edge is inserted in the adjacency list of v. |
w | is the target node of the new edge; the edge is added at the end of the adjacency list of w . |
index | is the index that will be assigned to the newly created edge. If negative or not given will use the next free index maxEdgeIndex() . Passing an edge index that is already in use results in an inconsistent data structure. Only specify this parameter if you know what you're doing! |
Creates a new edge at predefined positions in the adjacency lists.
Let w be the node whose adjacency list contains adjTgt
. Then, the created edge is (v
,w).
v | is the source node of the new edge; the edge is added at the end of the adjacency list of v . |
adjTgt | is the adjacency entry after which the new edge is inserted in the adjacency list of w. |
index | is the index that will be assigned to the newly created edge. If negative or not given will use the next free index maxEdgeIndex() . Passing an edge index that is already in use results in an inconsistent data structure. Only specify this parameter if you know what you're doing! |
Creates a new edge (v
,w
) and returns it.
v | is the source node of the newly created edge. |
w | is the target node of the newly created edge. |
index | is the index that will be assigned to the newly created edge. If negative or not given will use the next free index maxEdgeIndex() . Passing an edge index that is already in use results in an inconsistent data structure. Only specify this parameter if you know what you're doing! |
|
inline |
Creates a new edge at predefined positions in the adjacency lists.
Let v either be the node src
or the node whose adjacency list contains the adjEntry src
, and w either the node tgt
or the node whose adjacency list contains the adjEntry tgt
. Then, the created edge is (v,w).
src | is v or the adjacency entry before / after which the new edge is inserted in the adjacency list of v. |
dirSrc | specifies if the edge is inserted before or after adjSrc . |
tgt | is w or the adjacency entry before / after which the new edge is inserted in the adjacency list of w. |
dirTgt | specifies if the edge is inserted before or after adjTgt . |
index | is the index that will be assigned to the newly created edge. If negative or not given will use the next free index maxEdgeIndex() . Passing an edge index that is already in use results in an inconsistent data structure. Only specify this parameter if you know what you're doing! |
|
inline |
Creates a new node and returns it.
index | is the index that will be assigned to the newly created node. If negative or not given will use the next free index maxNodeIndex() . Passing a node index that is already in use results in an inconsistent data structure. Only specify this parameter if you know what you're doing! |
|
inlineprotectedvirtual |
Callback notifying subclasses that insert() copied a node.
userData | value returned from the initial preInsert() call |
original | the original node |
copy | the created copy |
Reimplemented in ogdf::GraphCopyBase.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Overwrites this graph to be a copy of G
.
The assignment operator assures that the adjacency lists of nodes in the constructed graph are in the same order as the adjacency lists in G
. This is in particular important when dealing with embedded graphs.
copy | is the graph to be copied. |
|
inlineprotectedvirtual |
Callback notifying subclasses that an insert() call has finished.
userData | value returned from the initial preInsert() call |
newNodes | final number of created nodes |
newEdges | final number of created edges |
|
inlineprotectedvirtual |
Callback notifying subclasses that some graph is about to be insert() -ed.
See its implementation in GraphCopy for an example.
copyEmbedding | value of the template parameter copyEmbedding of the insert() call |
copyIDs | value of the template parameter copyIDs of the insert() call |
notifyObservers | value of the template parameter notifyObservers of the insert() call |
edgeFilter | true if the insert variant with an edge filter instead of an iterator is used |
nodeMap | value of the template parameter nodeMap of the insert() call |
edgeMap | value of the template parameter edgeMap of the insert() call |
newNodes | pointer to the counter of inserted nodes, will be valid until after postInsert() |
newEdges | pointer to the counter of inserted edges, will be valid until after postInsert() |
Reimplemented in ogdf::GraphCopyBase.
Creates a new edge object with id index
and corresponding AdjElements and adds it to the list of edges.
Registered EdgeArrays won't get resized and GraphObservers also won't get notified of the new edge.
src | The source node of the new edge. |
tgt | The target node of the new edge. |
index | The index of the new edge. |
|
inlineprivate |
|
inline |
void ogdf::Graph::resetEdgeIdCount | ( | int | maxId | ) |
Resets the edge id count to maxId
.
The next edge will get edge id maxId
+1. Use this function with caution! It is provided as an efficient way to reduce the edge id count. The Graph class increments the edge id count whenever an edge is created; free edge ids resulting from removing edges are not reused (there is not something like a freelist).
This function is , e.g., useful, when a lot of edges has been added and all these edges are removed again (without creating other new edges meanwile). Then, it is safe to reduce the edge id count to the value it had before, cf. the following code snippet:
Reducing the edge id count will reduce the memory consumption of edge arrays associated with the graph.
maxId
<= maximal edge id in the graph.maxId | is an upper bound of the edge ids in the graph. |
void ogdf::Graph::resetNodeIdCount | ( | int | maxId | ) |
void ogdf::Graph::restoreAllEdges | ( | ) |
Restore all hidden edges and invalidate all HiddenEdgeSets.
void ogdf::Graph::reverseAdjEdges | ( | ) |
Reverses all adjacency lists.
|
inline |
void ogdf::Graph::reverseAllEdges | ( | ) |
Reverses all edges in the graph.
void ogdf::Graph::reverseEdge | ( | edge | e | ) |
Reverses the edge e
, i.e., exchanges source and target node.
Searches and returns an edge connecting nodes v
and w
in time O( min(deg(v
), deg(w
))).
v | is the first endpoint of the edge to be searched. |
w | is the second endpoint of the edge to be searched. |
directed | iff set to true, enforces that v must be the source node and w the target node of the edge. |
v
,w
) (or (w
,v
) for !directed
) if such an edge exists, nullptr otherwise.
|
inline |
Sorts the adjacency list of node v
according to newOrder
.
newOrder
contains exactly the adjacency entries of v!
ADJ_ENTRY_LIST | is the type of the input adjacency entry list. |
v | is the node whose adjacency list will be sorted. |
newOrder | is the list of adjacency entries of v in the new order. |
|
inline |
Sorts the adjacency list of node v
according to the range denoted by two iterators.
begin
... end
contains exactly the adjacency entries of v!
IT | is the type of the input adjacency entry list iterator. |
v | is the node whose adjacency list will be sorted. |
begin | is the iterator to the adjacency entry that should come first |
end | is the iterator one past the adjacency entry that should come last |
Splits edge e
into two edges introducing a new node.
Let e=
(v,w). Then, the resulting two edges are e=(v,u) and e'=(u,w), where u is a new node.
e
is modified by this operation.e | is the edge to be split. |
Reimplemented in ogdf::PlanRep, ogdf::GraphCopy, ogdf::PlanRepExpansion, ogdf::PlanRepInc, ogdf::PlanRepUML, and ogdf::ClusterPlanRep.
Splits a node while preserving the order of adjacency entries.
This method splits a node v into two nodes vl and vr. Node vl receives all adjacent edges of v from adjStartLeft
until the edge preceding adjStartRight
, and vr the remaining nodes (thus adjStartRight
is the first edge that goes to vr). The order of adjacency entries is preserved. Additionally, a new edge (vl,vr) is created, such that this edge is inserted before adjStartLeft
and adjStartRight
in the adjacency lists of vl and vr.
When adjStartLeft
and adjStartRight
are the same, vl receives all edges and the edge (vl, vr) is inserted before adjStartLeft
in the adjacency list of vl.
Node v is modified to become node vl, and node vr is returned. This method is useful when modifying combinatorial embeddings.
adjStartLeft | is the first entry that goes to the left node. |
adjStartRight | is the first entry that goes to the right node. |
Undoes a split operation.
For two edges eIn
= (x,u) and eOut
= (u,y), removes node u by joining eIn
and eOut
. Edge eOut
is removed and eIn
is reused.
eIn
and eOut
are the only edges incident with u and none of them is a self-loop.eIn | is the (only) incoming edge of u. |
eOut | is the (only) outgoing edge of u. |
Reimplemented in ogdf::GraphCopy, and ogdf::PlanRepExpansion.
void ogdf::Graph::unsplit | ( | node | u | ) |
Undoes a split operation.
Removes node u
by joining the two edges adjacent to u
. The outgoing edge of u
is removed and the incoming edge is reused
u
has exactly one incoming and one outgoing edge, and none of them is a self-loop.u | is the node to be unsplit. |
|
friend |
internal::GraphObjectContainer<EdgeElement> ogdf::Graph::edges |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
internal::GraphObjectContainer<NodeElement> ogdf::Graph::nodes |