[Lemon-user] How to construct a planar drawing?
Szabolcs Horvát
szhorvat at gmail.com
Tue May 15 16:15:52 CEST 2018
I think I found another problem. Running the drawing algorithm on a graph
with no edges and less than 3 vertices causes a crash. Of course, it is
easy to work around this. But it would be nice to have it fixed.
Minimal example with the singleton graph:
#include <lemon/static_graph.h>
#include <lemon/planarity.h>
#include <utility>
#include <vector>
using namespace lemon;
using namespace std;
int main() {
StaticDigraph digraph;
vector<pair<int,int>> edges = {}; // already sorted
digraph.build(1, edges.begin(), edges.end());
typedef Undirector<StaticDigraph> Graph;
Graph graph(digraph);
PlanarEmbedding<Graph> embedding(graph);
embedding.run(false);
PlanarDrawing<Graph> drawing(graph);
drawing.run(embedding.embeddingMap());
return 0;
}
On Tue, 15 May 2018 at 14:40, Szabolcs Horvát <szhorvat at gmail.com> wrote:
> Thanks for the clarification Balázs!
>
> On Tue, 15 May 2018 at 14:21, Balázs Dezső <deba.mf at gmail.com> wrote:
>
>> I have also filed a bug and created a patch:
>> http://lemon.cs.elte.hu/trac/lemon/ticket/610
>>
>> On Tue, May 15, 2018 at 2:02 PM Balázs Dezső <deba.mf at gmail.com> wrote:
>>
>>> This looks to be a bug in lemon. If you need a quick workaround, then
>>> pass an embedding to the run() function, like here:
>>>
>>> http://lemon.cs.elte.hu/trac/lemon/browser/lemon/test/planarity_test.cc#L249
>>>
>>> On Tue, May 15, 2018 at 1:38 PM Szabolcs Horvát <szhorvat at gmail.com>
>>> wrote:
>>>
>>>> Hello everyone,
>>>>
>>>> I am new to Lemon, and I am trying to construct a PlanarDrawing of a
>>>> graph.
>>>>
>>>> It's not working, and I'm not quite sure what I am doing wrong. The
>>>> analogous way of using PlanarEmbedding worked fine.
>>>>
>>>> Here's a minimal example (to be compiled as C++11):
>>>>
>>>> #include <lemon/static_graph.h>
>>>>
>>>> #include <lemon/planarity.h>
>>>>
>>>>
>>>> #include <utility>
>>>>
>>>> #include <vector>
>>>>
>>>> #include <iostream>
>>>>
>>>>
>>>> using namespace lemon;
>>>>
>>>> using namespace std;
>>>>
>>>>
>>>> int main() {
>>>>
>>>> StaticDigraph digraph;
>>>>
>>>>
>>>> vector<pair<int,int>> edges = {{0, 1}, {0, 2}, {1, 2}}; // already sorted
>>>>
>>>> digraph.build(3, edges.begin(), edges.end());
>>>>
>>>>
>>>> typedef Undirector<StaticDigraph> Graph;
>>>>
>>>> Graph graph (digraph);
>>>>
>>>>
>>>> PlanarDrawing<Graph> drawing(graph);
>>>>
>>>> drawing.run();
>>>>
>>>>
>>>> return 0;
>>>>
>>>> }
>>>>
>>>>
>>>> The error I get is:
>>>>
>>>> type 'const
>>>> lemon::PlanarEmbedding<lemon::Undirector<lemon::StaticDigraph> >' does not
>>>> provide a subscript operator
>>>>
>>>> Arc ee = embedding[_graph.direct(e, true)];
>>>>
>>>> I'm not quite sure what to make of it.
>>>>
>>>> Can anyone point out my mistake?
>>>>
>>>> Best regards,
>>>> Szabolcs
>>>> _______________________________________________
>>>> Lemon-user mailing list
>>>> Lemon-user at lemon.cs.elte.hu
>>>> http://lemon.cs.elte.hu/mailman/listinfo/lemon-user
>>>>
>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lemon.cs.elte.hu/pipermail/lemon-user/attachments/20180515/89055dca/attachment.html>
More information about the Lemon-user
mailing list