• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

CyberZHG / GraphLayout / 21120124705

18 Jan 2026 11:02PM UTC coverage: 88.936% (-1.0%) from 89.943%
21120124705

Pull #4

github

web-flow
Merge 105737a80 into df283e449
Pull Request #4: Add setting for arrow shapes

14 of 26 new or added lines in 4 files covered. (53.85%)

4 existing lines in 1 file now uncovered.

1262 of 1419 relevant lines covered (88.94%)

5224.09 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

60.61
/src/common/graph_attributes.cpp
1
#include "common/graph_attributes.h"
2

3
#include <functional>
4
#include <utility>
5
#include <ranges>
6
#include <format>
7
using namespace std;
8
using namespace graph_layout;
9

10
const string AttributeRankDir::TOP_TO_BOTTOM = "tb";
11
const string AttributeRankDir::BOTTOM_TO_TOP = "bt";
12
const string AttributeRankDir::LEFT_TO_RIGHT = "lr";
13
const string AttributeRankDir::RIGHT_TO_LEFT = "rl";
14

15
const string AttributeShape::NONE = "none";
16
const string AttributeShape::CIRCLE = "circle";
17
const string AttributeShape::DOUBLE_CIRCLE = "doublecircle";
18
const string AttributeShape::ELLIPSE = "ellipse";
19
const string AttributeShape::RECT = "rect";
20
const string AttributeShape::RECORD = "record";
21

22
const string AttributeSplines::LINE = "line";
23
const string AttributeSplines::SPLINE = "spline";
24

25
const string AttributeArrowShape::NONE = "none";
26
const string AttributeArrowShape::NORMAL = "normal";
27
const string AttributeArrowShape::EMPTY = "empty";
28

29
const string Attributes::MONOSPACE_FONT_FAMILY = R"(ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace)";
30

31
unordered_map<string_view, string> Attributes::DEFAULT_GRAPH_ATTRIBUTE_VALUES = {
32
    {ATTR_KEY_RANK_DIR, AttributeRankDir::TOP_TO_BOTTOM},
33
    {ATTR_KEY_BG_COLOR, "none"},
34
    {ATTR_KEY_FONT_NAME, "Times,serif"},
35
    {ATTR_KEY_FONT_SIZE, "14"},
36
};
37

38
unordered_map<string_view, string> Attributes::DEFAULT_VERTEX_ATTRIBUTE_VALUES = {
39
    {ATTR_KEY_LABEL, ""},
40
    {ATTR_KEY_SHAPE, AttributeShape::CIRCLE},
41
};
42

43
unordered_map<string_view, string> Attributes::DEFAULT_EDGE_ATTRIBUTE_VALUES = {
44
    {ATTR_KEY_LABEL, ""},
45
    {ATTR_KEY_TAIL_LABEL, ""},
46
    {ATTR_KEY_HEAD_LABEL, ""},
47
    {ATTR_KEY_LABEL_DISTANCE, "2.0"},
48
    {ATTR_KEY_SPLINES, "line"},
49
    {ATTR_KEY_ARROW_HEAD, AttributeArrowShape::NORMAL},
50
    {ATTR_KEY_ARROW_TAIL, AttributeArrowShape::NONE},
51
};
52

53
Attribute::Attribute() = default;
×
54

55
Attribute::Attribute(const string& value) : _raw(value) {
×
56
}
×
57

58
void Attribute::set(const string &value) {
×
59
    _raw = value;
×
60
}
×
61

62
const string& Attribute::value() const {
×
63
    return _raw;
×
64
}
65

66
string Attributes::graphAttributes(const string_view& key) const {
1,461✔
67
    if (const auto it = _graphAttributes.find(key); it != _graphAttributes.end()) {
1,461✔
68
        return it->second;
73✔
69
    }
70
    return DEFAULT_GRAPH_ATTRIBUTE_VALUES[key];
1,388✔
71
}
72

73
void Attributes::setGraphAttributes(const string_view& key, const string &value) {
25✔
74
    _graphAttributes[key] = value;
25✔
75
}
25✔
76

77
void Attributes::setGraphAttributes(const unordered_map<string_view, string>& attributes) {
×
78
    _graphAttributes = attributes;
×
79
}
×
80

81
string Attributes::vertexAttributes(const int u, const string_view& key) const {
1,612✔
82
    if (const auto vIt = _vertexAttributes.find(u); vIt != _vertexAttributes.end()) {
1,612✔
83
        if (const auto it = vIt->second.find(key); it != vIt->second.end()) {
1,608✔
84
            return it->second;
466✔
85
        }
86
    }
87
    if (const auto it = _vertexDefaultAttributes.find(key); it != _vertexDefaultAttributes.end()) {
1,146✔
88
        return it->second;
16✔
89
    }
90
    if (const auto it = DEFAULT_VERTEX_ATTRIBUTE_VALUES.find(key); it != DEFAULT_VERTEX_ATTRIBUTE_VALUES.end()) {
1,130✔
91
        return it->second;
332✔
92
    }
93
    return graphAttributes(key);
798✔
94
}
95

96
void Attributes::setVertexAttributes(const int u, const string_view& key, const string &value) {
233✔
97
    _vertexAttributes[u][key] = value;
233✔
98
}
233✔
99

100
void Attributes::setVertexAttributes(const int u, const unordered_map<string_view, string>& attributes) {
×
101
    _vertexAttributes[u] = attributes;
×
102
}
×
103

104
string Attributes::edgeAttributes(const int u, const string_view& key) const {
2,315✔
105
    if (const auto eIt = _edgeAttributes.find(u); eIt != _edgeAttributes.end()) {
2,315✔
106
        if (const auto it = eIt->second.find(key); it != eIt->second.end()) {
316✔
107
            return it->second;
40✔
108
        }
109
    }
110
    if (const auto it = _edgeDefaultAttributes.find(key); it != _edgeDefaultAttributes.end()) {
2,275✔
111
        return it->second;
6✔
112
    }
113
    if (const auto it = DEFAULT_EDGE_ATTRIBUTE_VALUES.find(key); it != DEFAULT_EDGE_ATTRIBUTE_VALUES.end()) {
2,269✔
114
        return it->second;
1,707✔
115
    }
116
    return graphAttributes(key);
562✔
117
}
118

119
void Attributes::setEdgeAttributes(const int u, const string_view& key, const string &value) {
39✔
120
    _edgeAttributes[u][key] = value;
39✔
121
}
39✔
122

123
void Attributes::setEdgeAttributes(const int u, const string_view& key, const double value) {
1✔
124
    _edgeAttributes[u][key] = format("{}", value);
1✔
125
}
1✔
126

127
void Attributes::setEdgeAttributes(const int u, const unordered_map<string_view, string>& mapping) {
×
128
    _edgeAttributes[u] = mapping;
×
129
}
×
130

131
void Attributes::transferEdgeAttributes(const int u, const int v) {
×
132
    if (_edgeAttributes.contains(u)) {
×
133
        _edgeAttributes[v] = _edgeAttributes[u];
×
134
    }
135
}
×
136

137
string Attributes::rankDir() const {
82✔
138
    return graphAttributes(ATTR_KEY_RANK_DIR);
82✔
139
}
140

141
void Attributes::setRankDir(const string &value) {
16✔
142
    setGraphAttributes(ATTR_KEY_RANK_DIR, value);
16✔
143
}
16✔
144

145
void Attributes::setVertexDefaultShape(const string& value) {
1✔
146
    _vertexDefaultAttributes[ATTR_KEY_SHAPE] = value;
1✔
147
}
1✔
148

149
void Attributes::setEdgeDefaultSplines(const string& value) {
×
150
    _edgeDefaultAttributes[ATTR_KEY_SPLINES] = value;
×
151
}
×
152

153
void Attributes::setVertexDefaultMonospace() {
1✔
154
    _vertexDefaultAttributes[ATTR_KEY_FONT_NAME] = MONOSPACE_FONT_FAMILY;
1✔
155
}
1✔
156

157
void Attributes::setEdgeDefaultMonospace() {
1✔
158
    _edgeDefaultAttributes[ATTR_KEY_FONT_NAME] = MONOSPACE_FONT_FAMILY;
1✔
159
}
1✔
160

161
void Attributes::setVertexShape(const int u, const string &value) {
6✔
162
    setVertexAttributes(u, ATTR_KEY_SHAPE, value);
6✔
163
}
6✔
164

165
void Attributes::setEdgeSplines(const int edgeId, const string& value) {
×
166
    setEdgeAttributes(edgeId, ATTR_KEY_SPLINES, value);
×
167
}
×
168

169
void Attributes::setEdgeTailLabel(const int edgeId, const string& label) {
1✔
170
    setEdgeAttributes(edgeId, ATTR_KEY_TAIL_LABEL, label);
1✔
171
}
1✔
172

173
void Attributes::setEdgeHeadLabel(const int edgeId, const string& label) {
1✔
174
    setEdgeAttributes(edgeId, ATTR_KEY_HEAD_LABEL, label);
1✔
175
}
1✔
176

177
void Attributes::setEdgeLabelDistance(const int edgeId, const double scale) {
1✔
178
    setEdgeAttributes(edgeId, ATTR_KEY_LABEL_DISTANCE, scale);
1✔
179
}
1✔
180

NEW
181
void Attributes::setEdgeDefaultArrowHead(const string& value) {
×
NEW
182
    _edgeDefaultAttributes[ATTR_KEY_ARROW_HEAD] = value;
×
NEW
183
}
×
184

NEW
185
void Attributes::setEdgeDefaultArrowTail(const string& value) {
×
NEW
186
    _edgeDefaultAttributes[ATTR_KEY_ARROW_TAIL] = value;
×
NEW
187
}
×
188

NEW
189
void Attributes::setEdgeArrowHead(const int edgeId, const string& value) {
×
NEW
190
    setEdgeAttributes(edgeId, ATTR_KEY_ARROW_HEAD, value);
×
NEW
191
}
×
192

NEW
193
void Attributes::setEdgeArrowTail(const int edgeId, const string& value) {
×
NEW
194
    setEdgeAttributes(edgeId, ATTR_KEY_ARROW_TAIL, value);
×
NEW
195
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc