[Lemon-commits] Balazs Dezso: Planar drawing algorithm now works...
Lemon HG
hg at lemon.cs.elte.hu
Wed Oct 17 20:07:38 CEST 2018
details: http://lemon.cs.elte.hu/hg/lemon/rev/6b79d93e812f
changeset: 1400:6b79d93e812f
user: Balazs Dezso <deba [at] google.com>
date: Wed Oct 17 17:52:11 2018 +0200
description:
Planar drawing algorithm now works for less than 3 nodes (#611)
diffstat:
lemon/planarity.h | 9 +++++++++
test/planarity_test.cc | 39 ++++++++++++++++++++++++++++++++++++---
2 files changed, 45 insertions(+), 3 deletions(-)
diffs (78 lines):
diff --git a/lemon/planarity.h b/lemon/planarity.h
--- a/lemon/planarity.h
+++ b/lemon/planarity.h
@@ -2398,6 +2398,15 @@
void run(const EmbeddingMap& embedding) {
typedef SmartEdgeSet<Graph> AuxGraph;
+ if (countNodes(_graph) < 3) {
+ int y = 0;
+ for (typename Graph::NodeIt n(_graph); n != INVALID; ++n) {
+ _point_map[n].x = 0;
+ _point_map[n].y = y++;
+ }
+ return;
+ }
+
if (3 * countNodes(_graph) - 6 == countEdges(_graph)) {
drawing(_graph, embedding, _point_map);
return;
diff --git a/test/planarity_test.cc b/test/planarity_test.cc
--- a/test/planarity_test.cc
+++ b/test/planarity_test.cc
@@ -30,10 +30,40 @@
using namespace lemon;
using namespace lemon::dim2;
-const int lgfn = 4;
+const int lgfn = 8;
const std::string lgf[lgfn] = {
"@nodes\n"
"label\n"
+ "@edges\n"
+ " label\n",
+
+ "@nodes\n"
+ "label\n"
+ "0\n"
+ "@edges\n"
+ " label\n",
+
+ "@nodes\n"
+ "label\n"
+ "0\n"
+ "1\n"
+ "@edges\n"
+ " label\n"
+ "0 1 0\n",
+
+ "@nodes\n"
+ "label\n"
+ "0\n"
+ "1\n"
+ "2\n"
+ "@edges\n"
+ " label\n"
+ "0 1 0\n"
+ "1 2 1\n"
+ "2 0 2\n",
+
+ "@nodes\n"
+ "label\n"
"0\n"
"1\n"
"2\n"
@@ -136,8 +166,11 @@
++face_num;
}
}
- check(face_num + countNodes(graph) - countConnectedComponents(graph) ==
- countEdges(graph) + 1, "Euler test does not passed");
+
+ if (face_num != 0) {
+ check(face_num + countNodes(graph) - countConnectedComponents(graph) ==
+ countEdges(graph) + 1, "Euler test does not passed");
+ }
}
void checkKuratowski(const Graph& graph, PE& pe) {
More information about the Lemon-commits
mailing list