File: MixedModel.h

package info (click to toggle)
tulip 6.0.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 196,224 kB
  • sloc: cpp: 571,851; ansic: 13,983; python: 4,105; sh: 1,555; yacc: 522; xml: 484; makefile: 168; pascal: 148; lex: 55
file content (110 lines) | stat: -rw-r--r-- 4,241 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/**
 *
 * This file is part of Tulip (https://tulip.labri.fr)
 *
 * Authors: David Auber and the Tulip development Team
 * from LaBRI, University of Bordeaux
 *
 * Tulip is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation, either version 3
 * of the License, or (at your option) any later version.
 *
 * Tulip is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 *
 */
#ifndef _MixedModel_H
#define _MixedModel_H

#include <tulip/LayoutProperty.h>
#include <tulip/PlanarConMap.h>

#include <tulip/tuliphash.h>

/** \addtogroup layout */

/** This plugin is an implementation of the planar polyline graph
 *  drawing algorithm, the mixed model algorithm, first published as:
 *
 *  C. Gutwenger and P. Mutzel, \n
 *  "Planar Polyline Drawings with Good Angular Resolution", \n
 *  "Lecture Notes In Computer Science, Vol. 1547" \n
 *  "Proceedings of the 6th International Symposium on Graph Drawing (GD 1998)," \n
 *  pages "167--182", 1999, doi: <a
 * href=\"https://doi.org/10.1007/3-540-37623-2_13\">https://doi.org/10.1007/3-540-37623-2_13</a>\n
 *
 *  Let n be the number of nodes, the original algorithm complexity is in O(n).\n
 *  But the implementation of the canonical ordering has not been made in O(n).\n
 *  This version of the algorithm considers each connected component of the graph,
 *  tests if it is planar or not. If not, it computes a planar subgraphs, which is
 *  a maximal planar "sub-map". Then an area aware version of Gutwenger and Mutzel 's
 *  algorithm is used, and if the connected component was not planar, it adds the
 *  "unplanar" edges in 3D. Finally, it uses the Connected Component Packing plugin
 *  of Tulip Software to pack the connected components.\n
 *
 */
class MixedModel : public tlp::LayoutAlgorithm {
public:
  PLUGININFORMATION("Mixed Model", "Romain BOURQUI ", "09/11/2005",
                    "Implements the planar polyline graph drawing algorithm, the mixed model "
                    "algorithm, first published as:<br/>"
                    "<b>Planar Polyline Drawings with Good Angular Resolution</b>, C. Gutwenger "
                    "and P. Mutzel, LNCS, Vol. 1547 pages 167--182 (1999),<br/>"
                    "doi: <a "
                    "href=\"https://doi.org/10.1007/3-540-37623-2_13\">https://doi.org/10.1007/"
                    "3-540-37623-2_13</a>",
                    "1.0", "Planar")
  MixedModel(const tlp::PluginContext *context);
  ~MixedModel() override;
  bool run() override;
  bool check(std::string &) override;

private:
  std::vector<tlp::edge> getPlanarSubGraph(tlp::PlanarConMap *graph,
                                           const std::vector<tlp::edge> &unplanar_edges);
  void initPartition();
  void assignInOutPoints();
  void computeCoords();
  void placeNodesEdges();

  tlp::edge existEdge(tlp::node n, tlp::node v) {
    return carte->existEdge(n, v, false);
  }

  tlp::node rightV(unsigned int k);
  tlp::node leftV(unsigned int k);
  int next_right(unsigned int k, const tlp::node v);
  int next_left(unsigned int k, const tlp::node v);

  tlp::PlanarConMap *carte;
  std::vector<std::vector<tlp::node>> V;
  tlp_hash_map<tlp::node, tlp::Coord> NodeCoords;

  tlp_hash_map<tlp::node, int> outl;
  tlp_hash_map<tlp::node, int> outr;
  tlp_hash_map<tlp::node, int> inl;
  tlp_hash_map<tlp::node, int> inr;

  tlp_hash_map<tlp::node, unsigned int> rank;
  tlp_hash_map<tlp::node, std::vector<tlp::edge>> EdgesIN;
  tlp_hash_map<tlp::node, std::vector<tlp::edge>> EdgesOUT;

  tlp_hash_map<tlp::edge, std::vector<tlp::Coord>> InPoints;
  tlp_hash_map<tlp::edge, tlp::Coord> OutPoints;

  tlp::Graph *Pere;
  tlp::PlanarConMap *graphMap;
  tlp::Graph *currentGraph;
  std::vector<tlp::edge> dummy;
  tlp_hash_map<tlp::node, std::vector<tlp::Coord>> out_points;
  tlp::MutableContainer<tlp::Coord> nodeSize;
  std::vector<tlp::edge> unplanar_edges;
  bool planar;
  tlp::SizeProperty *sizeResult;
  tlp::IntegerProperty *shapeResult;
};

#endif