Problems compiling Planar embedding

7 views
Skip to first unread message

je e

unread,
Dec 16, 2025, 10:15:25 AM (10 days ago) Dec 16
to ogdf
I would like to spring-embed a (large) graph of which I know it is planar (on linux)
I downloaded the last version of OGDF and compiled and installed it (hopefully correctly, as root)  Can anybody help me?

My graph will be a quite large graph, with a hierarchical structure.

Chatgtp proposed this program, but it seems to be missing the 

#include <ogdf/planarity/PlanarEmbedding.h>

The proposed headers are 
#include <ogdf/basic/Graph.h>
#include <ogdf/basic/GraphAttributes.h>

#include <ogdf/planarity/PlanarizationLayout.h>
#include <ogdf/planarity/PlanarEmbedding.h>
#include <ogdf/planarity/BoyerMyrvold.h>

#include <ogdf/energybased/FMMMLayout.h>

#include <fstream>
using namespace ogdf

the graph is then 

  node v1 = G.newNode();
    node v2 = G.newNode();
    node v3 = G.newNode();
    node v4 = G.newNode();

    G.newEdge(v1, v2);
    G.newEdge(v2, v3);
    G.newEdge(v3, v1);
    G.newEdge(v3, v4);

 

Dagobert Smart

unread,
Dec 17, 2025, 8:49:33 AM (9 days ago) Dec 17
to ogdf
Hello,

ChatGPT is clearly hallucinating the header.
A general programming tip: If ChatGPT does not help you, consulting the respective documentation might be a good idea.

In fact, the OGDF documentation includes several helpful examples:
* Documentation: https://ogdf.netlify.app/
* How-to Examples: https://ogdf.netlify.app/examples
* Layout Algorithm Tutorial (especially see "Energy-based layout"): https://ogdf.netlify.app/ex-layout
* List of energy-based layouts: https://ogdf.netlify.app/group__gd-energy

The FMMMLayout used in the layout algorithm tutorial should already give you good results. You can modify the example to create your graph using `G.newNode()` and `G.newEdge()` if you want to create it manually instead of reading in a file.

Obviously spring embedders (aka energy-based layout algorithms) will not always create a planar drawing, even if the graph is planar. If you want your drawing to be planar and an energy-based approach does not do the trick, you can use a planar layout like the ones listed below:
I hope this helps you.

Best regards,
Dagobert
Reply all
Reply to author
Forward
0 new messages