1 /** \file
2  * \brief Declaration of class SplitHeuristic.
3  *
4  * \author Andrea Wagner
5  *
6  * \par License:
7  * This file is part of the Open Graph Drawing Framework (OGDF).
8  *
9  * \par
10  * Copyright (C)<br>
11  * See README.md in the OGDF root directory for details.
12  *
13  * \par
14  * This program is free software; you can redistribute it and/or
15  * modify it under the terms of the GNU General Public License
16  * Version 2 or 3 as published by the Free Software Foundation;
17  * see the file LICENSE.txt included in the packaging of this file
18  * for details.
19  *
20  * \par
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24  * GNU General Public License for more details.
25  *
26  * \par
27  * You should have received a copy of the GNU General Public
28  * License along with this program; if not, see
29  * http://www.gnu.org/copyleft/gpl.html
30  */
31 
32 #pragma once
33 
34 #include <ogdf/basic/EdgeArray.h>
35 #include <ogdf/layered/CrossingsMatrix.h>
36 #include <ogdf/simultaneous/TwoLayerCrossMinSimDraw.h>
37 
38 namespace ogdf {
39 
40 
41 //! The split heuristic for 2-layer crossing minimization.
42 /**
43  * @ingroup gd-layered-crossmin
44  */
45 class OGDF_EXPORT SplitHeuristic : public TwoLayerCrossMinSimDraw
46 {
47 public:
48 	//! Creates a new instance of the split heuristic.
SplitHeuristic()49 	SplitHeuristic() : m_cm(nullptr) { }
50 
51 	//! Creates a new instance of the split heuristic.
SplitHeuristic(const SplitHeuristic & crossMin)52 	SplitHeuristic(const SplitHeuristic &crossMin) : m_cm(nullptr) { }
53 
~SplitHeuristic()54 	~SplitHeuristic() {
55 		cleanup();
56 	}
57 
58 	//! Returns a new instance of the splitheurisitc with the same option settings.
clone()59 	TwoLayerCrossMinSimDraw *clone() const override { return new SplitHeuristic(*this); }
60 
61 	//! Initializes crossing minimization for hierarchy \a H.
62 	void init (const HierarchyLevels &levels) override;
63 
64 	//! Calls the split heuristic for level \p L.
65 	void call (Level &L) override;
66 
67 	//! Calls the median heuristic for level \p L (simultaneous drawing).
68 	void call (Level &L, const EdgeArray<uint32_t> *edgeSubGraphs) override;
69 
70 	//! Does some clean-up after calls.
71 	void cleanup () override;
72 
73 private:
74 	CrossingsMatrix *m_cm;
75 	Array<node> m_buffer;
76 
77 	void recCall(Level&, int low, int high);
78 };
79 
80 }
81