# HG changeset patch # User Balazs Dezso # Date 1539791531 -7200 # Node ID 6b79d93e812f3d99e00e90bd5c7a5d04f05f6cc1 # Parent 1e5da3fc4fbceced88d54f3429934054ba559c79 Planar drawing algorithm now works for less than 3 nodes (#611) diff -r 1e5da3fc4fbc -r 6b79d93e812f lemon/planarity.h --- a/lemon/planarity.h Tue May 15 14:16:35 2018 +0200 +++ b/lemon/planarity.h Wed Oct 17 17:52:11 2018 +0200 @@ -2398,6 +2398,15 @@ void run(const EmbeddingMap& embedding) { typedef SmartEdgeSet 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 -r 1e5da3fc4fbc -r 6b79d93e812f test/planarity_test.cc --- a/test/planarity_test.cc Tue May 15 14:16:35 2018 +0200 +++ b/test/planarity_test.cc Wed Oct 17 17:52:11 2018 +0200 @@ -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) {