File: test_edge_node_overlap_utilities.h

package info (click to toggle)
graphviz 14.0.5-2
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 139,388 kB
  • sloc: ansic: 141,938; cpp: 11,957; python: 7,766; makefile: 4,043; yacc: 3,030; xml: 2,972; tcl: 2,495; sh: 1,388; objc: 1,159; java: 560; lex: 423; perl: 243; awk: 156; pascal: 139; php: 58; ruby: 49; cs: 31; sed: 1
file content (69 lines) | stat: -rw-r--r-- 2,679 bytes parent folder | download | duplicates (2)
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
#include <string>
#include <string_view>
#include <unordered_map>

#include "svg_analyzer.h"

/// check options that can be controlled from the test case
struct tc_check_options {
  /// whether to check that there is not too much overlap
  bool check_max_edge_node_overlap = true;
  /// whether to check that there is enough overlap
  bool check_min_edge_node_overlap = true;
  /// whether to check that there is not too much overlap between edge stem and
  /// arrow
  bool check_max_edge_stem_arrow_overlap = true;
  /// whether to check that there is enough overlap between edge stem and arrow
  bool check_min_edge_stem_arrow_overlap = true;
};

struct check_options {
  /// whether to check that there is not too much overlap
  bool check_max_edge_node_overlap = true;
  /// whether to check that there is enough overlap
  bool check_min_edge_node_overlap = true;
  /// whether to check that there is not too much overlap between edge stem and
  /// arrow
  bool check_max_edge_stem_arrow_overlap = true;
  /// whether to check that there is enough overlap between edge stem and arrow
  bool check_min_edge_stem_arrow_overlap = true;
  /// maximum allowed overlap between edge and node
  double max_node_edge_overlap;
  /// minimum required overlap between edge and node
  double min_node_edge_overlap;
  /// map between primitive arrow shape and maximum allowed overlap between edge
  /// stem and arrow
  std::unordered_map<std::string_view, double> max_edge_stem_arrow_overlap;
  /// minimum required overlap between edge stem and arrow
  double min_edge_stem_arrow_overlap;
  /// rounding error caused by limited precision in SVG attribute values
  double svg_rounding_error;
};

struct graph_options {
  std::string_view rankdir = "TB";
  std::string_view node_shape = "polygon";
  double node_fontsize = 14;
  double node_penwidth = 1;
  std::string_view dir = "forward";
  double edge_penwidth = 1;
  double edge_arrowsize = 1;
  std::string_view primitive_arrowhead_shape = "normal";
  std::string_view primitive_arrowtail_shape = "normal";
  std::string_view arrowhead_modifier = "";
  std::string_view arrowtail_modifier = "";
};

struct write_options {
  std::string filename_base = "test_edge_node_overlap";
  bool write_svg_on_success = false;
  bool write_original_svg = false;
  bool write_recreated_svg = false;
  bool write_annotated_svg = true;
};

/// generate an SVG graph from the `dot` source and check that edges don't
/// overlap nodes
void test_edge_node_overlap(const graph_options &graph_options = {},
                            const tc_check_options &tc_check_options = {},
                            const write_options &write_options = {});