2024-05-06 16:32:01 +09:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
*/
|
2024-02-05 11:02:44 +09:00
|
|
|
#include <ogdf/basic/STNumbering.h>
|
|
|
|
#include <ogdf/fileformats/GraphIO.h>
|
|
|
|
|
|
|
|
#include <ogdf/planarity/PlanarSubgraphFast.h>
|
|
|
|
// #include <ogdf/planarity/PlanarSubgraphBoyerMyrvold.h>
|
|
|
|
#include <ogdf/planarity/MaximumPlanarSubgraph.h>
|
|
|
|
#include <ogdf/planarity/MaximalPlanarSubgraphSimple.h>
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
using namespace ogdf;
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char* argv[])
|
|
|
|
{
|
|
|
|
|
|
|
|
string inputFile = argv[1];
|
|
|
|
Graph G;
|
|
|
|
|
|
|
|
if (!GraphIO::read(G, inputFile, GraphIO::readGML)) {
|
|
|
|
std::cerr << "Could not read input.gml" << std::endl;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NodeArray<int> numbering(G);
|
2024-05-07 08:41:39 +09:00
|
|
|
computeSTNumbering(G, numbering, nullptr, nullptr, true);
|
2024-02-05 11:02:44 +09:00
|
|
|
OGDF_ASSERT(num == G.numberOfNodes());
|
|
|
|
|
|
|
|
// print after input
|
|
|
|
// graphPrinter(G);
|
2024-05-07 08:41:39 +09:00
|
|
|
// std::cout << "G Planarity: " << ogdf::isPlanar(G) << std::endl;
|
|
|
|
// std::cout << "Original number of nodes: " << G.numberOfNodes() << std::endl;
|
|
|
|
// std::cout << "Original number of edges: " << G.numberOfEdges() << std::endl;
|
2024-02-05 11:02:44 +09:00
|
|
|
|
|
|
|
// separator for planarization
|
|
|
|
// <-------------->
|
|
|
|
|
|
|
|
// PQ implementation to make planar subgraph
|
|
|
|
List<edge> *delEdges = new List<edge>; // empty list
|
|
|
|
|
2024-05-06 16:32:01 +09:00
|
|
|
PlanarSubgraphFast<int> psf;
|
|
|
|
// comment out to use default options
|
|
|
|
// psf.runs(1);
|
|
|
|
ogdf::MaximalPlanarSubgraphSimple<int> mps(psf);
|
2024-02-05 11:02:44 +09:00
|
|
|
mps.call(G, *delEdges);
|
|
|
|
|
|
|
|
|
2024-05-07 08:41:39 +09:00
|
|
|
// print edges removed
|
|
|
|
std::cout << delEdges->size() << std::endl;
|
2024-02-05 11:02:44 +09:00
|
|
|
|
|
|
|
|
|
|
|
// delete removed edges
|
2024-05-07 08:41:39 +09:00
|
|
|
// for (edge e: *delEdges) {
|
|
|
|
// // print removed edges
|
|
|
|
// // std::cout << e->adjSource() << std::endl;
|
|
|
|
// G.delEdge(e);
|
|
|
|
// }
|
2024-02-05 11:02:44 +09:00
|
|
|
|
|
|
|
|
|
|
|
// write processed graph to new gml file
|
|
|
|
// GraphIO::write(G, "output.gml", GraphIO::writeGML);
|
|
|
|
|
|
|
|
|
2024-05-07 08:41:39 +09:00
|
|
|
// std::cout << "G planarity: " << ogdf::isPlanar(G) << std::endl;
|
|
|
|
// std::cout << "Original number of nodes: " << G.numberOfNodes() << std::endl;
|
|
|
|
// std::cout << "Subgraph number of edges: " << G.numberOfEdges() << std::endl;
|
2024-02-05 11:02:44 +09:00
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|