Hierarchical graph representation used by GlobalSifting and GridSifting algorithms. More...
#include <ogdf/layered/BlockOrder.h>
Public Member Functions | |
BlockOrder (Hierarchy &hierarchy, bool longEdgesOnly=true) | |
~BlockOrder () | |
int | blocksCount () |
Returns the number of blocks. More... | |
void | globalSifting (int rho=1, int nRepeats=10, int *pNumCrossings=nullptr) |
Calls the global sifting algorithm on graph (its hierarchy). More... | |
HierarchyLevelsBase members | |
const ArrayLevel & | operator[] (int i) const override |
Returns the i-th level. More... | |
int | pos (node v) const override |
Returns the position of node v on its level. More... | |
int | size () const override |
Returns the number of levels. More... | |
const Hierarchy & | hierarchy () const override |
const Array< node > & | adjNodes (node v, TraversingDir dir) const override |
Returns the adjacent nodes of v . More... | |
Public Member Functions inherited from ogdf::HierarchyLevelsBase | |
HierarchyLevelsBase ()=default | |
HierarchyLevelsBase (const HierarchyLevelsBase &)=default | |
virtual | ~HierarchyLevelsBase () |
int | calculateCrossings () const |
Computes the total number of crossings. More... | |
int | calculateCrossings (int i) const |
Computes the number of crossings between level i and i+1 . More... | |
virtual int | high () const |
Returns the maximal array index of a level (= size()-1). More... | |
HierarchyLevelsBase & | operator= (const HierarchyLevelsBase &)=default |
Private Types | |
enum | Direction { Direction::Plus, Direction::Minus } |
Private Member Functions | |
void | buildAdjNodes () |
Builds lists of adjacent nodes (needed by HierarchyLevelsBase). More... | |
void | buildDummyNodesLists () |
Builds list of dummy nodes laying inside edge blocks. More... | |
void | buildHierarchy () |
Builds arrays that allow using BlockOrder as HierarchyLevelsBase implementation. More... | |
void | buildLevels () |
Builds levels of vertices from original graph. More... | |
void | deconstruct () |
Deletes levels and blocks owned by this instance of BlockOrder. More... | |
void | doInit (bool longEdgesOnly=true) |
Does some initialization. More... | |
int | siftingStep (Block *blockOfA) |
Performs sifting for a single block. More... | |
int | siftingSwap (Block *blockOfA, Block *blockOfB) |
Swaps two consecutive blocks. More... | |
void | sortAdjacencies () |
Creates sorted lists of neighbours for all blocks. More... | |
void | updateAdjacencies (Block *blockOfA, Block *blockOfB, Direction d) |
Updates adjacencies lists before swaping two blocks. More... | |
int | uswap (Block *blockOfA, Block *blockOfB, Direction d, int level) |
Calculates change of crossings made by a single swap. More... | |
Private Attributes | |
int | m_activeBlocksCount |
int | m_bestCrossings |
The lowest number of crossing found in the sifting step. More... | |
Array< int > | m_bestPerm |
The best found permutation in the sifting step. More... | |
Array< Block * > | m_Blocks |
The array of all blocks. More... | |
Array< int > | m_currentPerm |
The permutation modified in the sifting step. More... | |
Array< int > | m_currentPermInv |
Inversion of m_currenPerm. More... | |
EdgeArray< Block * > | m_EdgeBlocks |
The array of all edge blocks. More... | |
GraphCopy | m_GC |
The graph copy representing the topology of the proper hierarchy. More... | |
Hierarchy & | m_hierarchy |
The hierarchy on grid- and globalsifting operates. More... | |
EdgeArray< bool > | m_isActiveEdge |
Stores information about active edge blocks. More... | |
Array< ArrayLevel * > | m_levels |
The array of all levels. More... | |
NodeArray< Array< node > > | m_lowerAdjNodes |
(Sorted) adjacent nodes on lower level. More... | |
NodeArray< Block * > | m_NodeBlocks |
The array of all vertex blocks. More... | |
NodeArray< int > | m_nSet |
(Only used by buildAdjNodes().) More... | |
NodeArray< int > | m_pos |
The position of a node on its level. More... | |
NodeArray< int > | m_ranks |
The rank (level) of a node. More... | |
int | m_storedCrossings |
Numebr of crossings stored in the sifting step. More... | |
Array< int > | m_storedPerm |
The permutation from which the sifting step starts. More... | |
NodeArray< Array< node > > | m_upperAdjNodes |
(Sorted) adjacent nodes on upper level. More... | |
GridSifting | |
Array< int > | m_nNodesOnLvls |
int | m_verticalStepsBound |
int | verticalSwap (Block *b, int level) |
Moves block to next level. More... | |
int | localCountCrossings (const Array< int > &levels) |
Only used in verticalSwap(). More... | |
void | verticalStep (Block *b) |
Performs vertical step for block b. More... | |
void | gridSifting (int nRepeats=10) |
Calls the grid sifting algorithm on a graph (its hierarchy). More... | |
Additional Inherited Members | |
Public Types inherited from ogdf::HierarchyLevelsBase | |
enum | TraversingDir { TraversingDir::downward, TraversingDir::upward } |
Hierarchical graph representation used by GlobalSifting and GridSifting algorithms.
This representation is based on blocks. Each block is a single vertex from the original graph or edge that consists of some dummy vertices in hierarchical embedding of this graph.
BlockOrder stores permutation of blocks (their x-coordinates) and uses this information in translation to Hierarchy and HierarchyLevelsBase.
Definition at line 120 of file BlockOrder.h.
|
strongprivate |
Enumerator | |
---|---|
Plus | |
Minus |
Definition at line 122 of file BlockOrder.h.
|
inline |
Definition at line 195 of file BlockOrder.h.
|
explicit |
|
inlineoverridevirtual |
Returns the adjacent nodes of v
.
Implements ogdf::HierarchyLevelsBase.
Definition at line 184 of file BlockOrder.h.
|
inline |
Returns the number of blocks.
Definition at line 198 of file BlockOrder.h.
|
private |
Builds lists of adjacent nodes (needed by HierarchyLevelsBase).
|
private |
Builds list of dummy nodes laying inside edge blocks.
|
inlineprivate |
Builds arrays that allow using BlockOrder as HierarchyLevelsBase implementation.
Definition at line 274 of file BlockOrder.h.
|
private |
Builds levels of vertices from original graph.
|
private |
Deletes levels and blocks owned by this instance of BlockOrder.
|
private |
Does some initialization.
void ogdf::BlockOrder::globalSifting | ( | int | rho = 1 , |
int | nRepeats = 10 , |
||
int * | pNumCrossings = nullptr |
||
) |
Calls the global sifting algorithm on graph (its hierarchy).
void ogdf::BlockOrder::gridSifting | ( | int | nRepeats = 10 | ) |
Calls the grid sifting algorithm on a graph (its hierarchy).
|
inlineoverridevirtual |
Implements ogdf::HierarchyLevelsBase.
Definition at line 181 of file BlockOrder.h.
|
private |
Only used in verticalSwap().
|
inlineoverridevirtual |
Returns the i-th level.
Implements ogdf::HierarchyLevelsBase.
Definition at line 173 of file BlockOrder.h.
|
inlineoverridevirtual |
Returns the position of node v
on its level.
Implements ogdf::HierarchyLevelsBase.
Definition at line 176 of file BlockOrder.h.
|
private |
Performs sifting for a single block.
See SIFTING-STEP in papers.
Swaps two consecutive blocks.
See SIFTING-STEP in papers.
|
inlineoverridevirtual |
Returns the number of levels.
Implements ogdf::HierarchyLevelsBase.
Definition at line 179 of file BlockOrder.h.
|
private |
Creates sorted lists of neighbours for all blocks.
See function SORT-ADJACENCIES in paper.
|
private |
Updates adjacencies lists before swaping two blocks.
Updates adjacencies lists of two blocks and their neighbours in direction d
. This function is called before blocks are swapped. See UPDATE-ADJACENCIES in papers.
Calculates change of crossings made by a single swap.
Calculates change in number of crossing after swapping two consecutive blocks in current permutation. See USWAP in papers.
|
private |
Performs vertical step for block b.
See VERTICAL-STEP in papers.
|
private |
Moves block to next level.
|
private |
Definition at line 153 of file BlockOrder.h.
|
private |
The lowest number of crossing found in the sifting step.
Definition at line 137 of file BlockOrder.h.
|
private |
The best found permutation in the sifting step.
Definition at line 131 of file BlockOrder.h.
The array of all blocks.
Definition at line 144 of file BlockOrder.h.
|
private |
The permutation modified in the sifting step.
Definition at line 130 of file BlockOrder.h.
|
private |
Inversion of m_currenPerm.
Definition at line 134 of file BlockOrder.h.
The array of all edge blocks.
Definition at line 146 of file BlockOrder.h.
|
private |
The graph copy representing the topology of the proper hierarchy.
Definition at line 124 of file BlockOrder.h.
|
private |
The hierarchy on grid- and globalsifting operates.
Definition at line 155 of file BlockOrder.h.
|
private |
Stores information about active edge blocks.
Definition at line 148 of file BlockOrder.h.
|
private |
The array of all levels.
Definition at line 161 of file BlockOrder.h.
(Sorted) adjacent nodes on lower level.
Definition at line 163 of file BlockOrder.h.
|
private |
Definition at line 299 of file BlockOrder.h.
The array of all vertex blocks.
Definition at line 145 of file BlockOrder.h.
|
private |
(Only used by buildAdjNodes().)
Definition at line 166 of file BlockOrder.h.
|
private |
The position of a node on its level.
Definition at line 159 of file BlockOrder.h.
|
private |
The rank (level) of a node.
Definition at line 126 of file BlockOrder.h.
|
private |
Numebr of crossings stored in the sifting step.
Definition at line 136 of file BlockOrder.h.
|
private |
The permutation from which the sifting step starts.
Definition at line 129 of file BlockOrder.h.
(Sorted) adjacent nodes on upper level.
Definition at line 164 of file BlockOrder.h.
int ogdf::BlockOrder::m_verticalStepsBound |
Definition at line 302 of file BlockOrder.h.