Feat: benchmarked north, rome and steinlib

This commit is contained in:
Richard Wong 2024-05-07 08:41:39 +09:00
parent b05b8410d3
commit 803274cb80
Signed by: richard
GPG Key ID: 72948FBB6D359A6D
21 changed files with 658 additions and 33 deletions

4
.gitignore vendored
View File

@ -1,7 +1,3 @@
.vscode
make_graphs/bin
make_graphs/test_graphs
make_planar/bin
test_area
dpt
graph_datasets

7
benchmark_results/north/.gitignore vendored Normal file
View File

@ -0,0 +1,7 @@
dpt_planarizer
north.txt
north_result.csv
north_subset.txt
ogdf_mps_fast
output_north_dfs.txt
output_north_fast.txt

View File

@ -0,0 +1,33 @@
#!/bin/bash
FILE_LIST=$1
PROGRAM=$2
# Check if file_list.txt exists
if [ ! -f $FILE_LIST ]; then
echo "input file not found!"
exit 1
fi
INPUT_PATH=/home/richard/Projects/06_research/maximum_planar_subgraph/benchmark_data/graph_datasets/north/gml_non_planar/
# Read file paths from file_list.txt
while IFS= read -r INPUT_FILE; do
# Extract filename stem
filename=$(basename -- "$INPUT_FILE")
filename_stem="${filename%.*}"
# Run your program and capture its output
if [ "$PROGRAM" == "ogdf_mps_fast" ]; then
# do something if strings are equal
./$PROGRAM "$INPUT_PATH$INPUT_FILE"
elif [ "$PROGRAM" == "dpt_planarizer" ]; then
# do something if strings are not equal
./$PROGRAM "$INPUT_PATH$INPUT_FILE" 1000
fi
done < $FILE_LIST

6
benchmark_results/rome/.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
dpt_planarizer
ogdf_mps_fast
output_rome_dfs.txt
output_rome_fast.txt
rome.txt
rome_result.csv

View File

@ -0,0 +1,33 @@
#!/bin/bash
FILE_LIST=$1
PROGRAM=$2
# Check if file_list.txt exists
if [ ! -f $FILE_LIST ]; then
echo "input file not found!"
exit 1
fi
INPUT_PATH=/home/richard/Projects/06_research/maximum_planar_subgraph/benchmark_data/graph_datasets/rome/gml_non_planar/
# Read file paths from file_list.txt
while IFS= read -r INPUT_FILE; do
# Extract filename stem
filename=$(basename -- "$INPUT_FILE")
filename_stem="${filename%.*}"
# Run your program and capture its output
if [ "$PROGRAM" == "ogdf_mps_fast" ]; then
# do something if strings are equal
./$PROGRAM "$INPUT_PATH$INPUT_FILE"
elif [ "$PROGRAM" == "dpt_planarizer" ]; then
# do something if strings are not equal
./$PROGRAM "$INPUT_PATH$INPUT_FILE" 1000
fi
done < $FILE_LIST

9
benchmark_results/steinlib/.gitignore vendored Normal file
View File

@ -0,0 +1,9 @@
benchmark_steinlib.bash
dpt_planarizer
dpt_planarizer_random
dpt_planarizer_wilson
get_graph_char
ogdf_mps_cactus
ogdf_mps_fast
output_steinlib_*
steinlib.txt

3
data_process/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
graphml_to_gml
north_input.txt
rome_input.txt

View File

@ -0,0 +1,26 @@
#!/bin/bash
FILE_LIST=$1
echo "$FILE_LIST"
# Check if file_list.txt exists
if [ ! -f $FILE_LIST ]; then
echo "input file not found!"
exit 1
fi
INPUT_PATH=/home/richard/Projects/06_research/maximum_planar_subgraph/benchmark_data/graph_datasets/north/graphml/
# Read file paths from file_list.txt
while IFS= read -r INPUT_FILE; do
# Extract filename stem
filename=$(basename -- "$INPUT_FILE")
filename_stem="${filename%.*}"
# Modify output path
OUTPUT_PATH=/home/richard/Projects/06_research/maximum_planar_subgraph/benchmark_data/graph_datasets/north/gml/"$filename_stem".gml
# Call your program with input and modified output paths
./graphml_to_gml "$INPUT_PATH$INPUT_FILE" "$OUTPUT_PATH"
done < $FILE_LIST

View File

@ -0,0 +1,28 @@
#!/bin/bash
FILE_LIST=$1
echo "$FILE_LIST"
# Check if file_list.txt exists
if [ ! -f $FILE_LIST ]; then
echo "input file not found!"
exit 1
fi
INPUT_PATH=/home/richard/Projects/06_research/maximum_planar_subgraph/benchmark_data/graph_datasets/rome/graphml/
# Read file paths from file_list.txt
while IFS= read -r INPUT_FILE; do
# Extract filename stem
filename=$(basename -- "$INPUT_FILE")
filename_stem="${filename%.*}"
# Modify output path
OUTPUT_PATH=/home/richard/Projects/06_research/maximum_planar_subgraph/benchmark_data/graph_datasets/rome/gml/"$filename_stem".gml
echo "$filename_stem"
# Call your program with input and modified output paths
./graphml_to_gml "$INPUT_PATH$INPUT_FILE" "$OUTPUT_PATH"
done < $FILE_LIST

4
find_non_planar/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
north_gml_input.txt
ogdf_test_planar
rome_gml_input.txt
steinlib_gml_input.txt

View File

@ -0,0 +1,32 @@
#!/bin/bash
FILE_LIST=$1
echo "$FILE_LIST"
# Check if file_list.txt exists
if [ ! -f $FILE_LIST ]; then
echo "input file not found!"
exit 1
fi
INPUT_PATH=/home/richard/Projects/06_research/maximum_planar_subgraph/benchmark_data/graph_datasets/north/gml/
# Read file paths from file_list.txt
while IFS= read -r INPUT_FILE; do
# Extract filename stem
filename=$(basename -- "$INPUT_FILE")
filename_stem="${filename%.*}"
# Modify output path
OUTPUT_PATH=/home/richard/Projects/06_research/maximum_planar_subgraph/benchmark_data/graph_datasets/north/gml_non_planar/
# Run your program and capture its output
output=$(./ogdf_test_planar "$INPUT_PATH$INPUT_FILE")
# Check the output and perform actions accordingly
if [ "$output" -eq 0 ]; then
# it is not planar, copy to folder
cp "$INPUT_PATH$INPUT_FILE" "$OUTPUT_PATH$INPUT_FILE"
fi
done < $FILE_LIST

View File

@ -0,0 +1,34 @@
#!/bin/bash
FILE_LIST=$1
echo "$FILE_LIST"
# Check if file_list.txt exists
if [ ! -f $FILE_LIST ]; then
echo "input file not found!"
exit 1
fi
INPUT_PATH=/home/richard/Projects/06_research/maximum_planar_subgraph/benchmark_data/graph_datasets/rome/gml/
# Read file paths from file_list.txt
while IFS= read -r INPUT_FILE; do
# Extract filename stem
filename=$(basename -- "$INPUT_FILE")
filename_stem="${filename%.*}"
# Modify output path
OUTPUT_PATH=/home/richard/Projects/06_research/maximum_planar_subgraph/benchmark_data/graph_datasets/rome/gml_non_planar/
# Run your program and capture its output
output=$(./ogdf_test_planar "$INPUT_PATH$INPUT_FILE")
echo "$filename_stem"
# Check the output and perform actions accordingly
if [ "$output" -eq 0 ]; then
# it is not planar, copy to folder
cp "$INPUT_PATH$INPUT_FILE" "$OUTPUT_PATH$INPUT_FILE"
fi
done < $FILE_LIST

View File

@ -0,0 +1,34 @@
#!/bin/bash
FILE_LIST=$1
echo "$FILE_LIST"
# Check if file_list.txt exists
if [ ! -f $FILE_LIST ]; then
echo "input file not found!"
exit 1
fi
INPUT_PATH=/home/richard/Projects/06_research/maximum_planar_subgraph/benchmark_data/graph_datasets/steinlib/data/
# Read file paths from file_list.txt
while IFS= read -r INPUT_FILE; do
# Extract filename stem
filename=$(basename -- "$INPUT_FILE")
filename_stem="${filename%.*}"
# Modify output path
OUTPUT_PATH=/home/richard/Projects/06_research/maximum_planar_subgraph/benchmark_data/graph_datasets/steinlib/gml_non_planar/
# Run your program and capture its output
output=$(./ogdf_test_planar "$INPUT_PATH$INPUT_FILE")
echo "$filename_stem"
# Check the output and perform actions accordingly
if [ "$output" -eq 0 ]; then
# it is not planar, copy to folder
cp "$INPUT_PATH$INPUT_FILE" "$OUTPUT_PATH$INPUT_FILE"
fi
done < $FILE_LIST

2
make_graphs/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
bin
test_graphs

1
make_planar/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
bin

View File

@ -0,0 +1,26 @@
/* This code converts GraphML to gml
*
*/
#include <ogdf/fileformats/GraphIO.h>
#include <iostream>
using namespace ogdf;
int main(int argc, char* argv[])
{
string input_file = argv[1];
Graph G;
if (!GraphIO::read(G, input_file, GraphIO::readGML)) {
std::cerr << "Could not read input.gml" << std::endl;
return 1;
}
std::cout << G.numberOfNodes() << ", " << G.numberOfEdges() << std::endl;
return 0;
}

View File

@ -0,0 +1,27 @@
/* This code converts GraphML to gml
*
*/
#include <ogdf/fileformats/GraphIO.h>
#include <iostream>
using namespace ogdf;
int main(int argc, char* argv[])
{
string input_file = argv[1];
Graph G;
if (!GraphIO::read(G, input_file, GraphIO::readGraphML)) {
std::cerr << "Could not read input.gml" << std::endl;
return 1;
}
string output_file = argv[2];
GraphIO::write(G, output_file, GraphIO::writeGML);
return 0;
}

View File

@ -24,20 +24,19 @@ int main(int argc, char* argv[])
NodeArray<int> numbering(G);
int num = computeSTNumbering(G, numbering, nullptr, nullptr, true);
computeSTNumbering(G, numbering, nullptr, nullptr, true);
OGDF_ASSERT(num == G.numberOfNodes());
// print after input
// graphPrinter(G);
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;
// 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;
// separator for planarization
// <-------------->
// PQ implementation to make planar subgraph
std::cout << "start planarization" << std::endl;
// std::cout << "start planarization" << std::endl;
List<edge> *delEdges = new List<edge>; // empty list
PlanarSubgraphCactus<int> psc;
@ -45,24 +44,24 @@ int main(int argc, char* argv[])
mps.call(G, *delEdges);
std::cout << "Edges removed:" << delEdges->size() << std::endl;
std::cout << delEdges->size() << std::endl;
// delete removed edges
for (edge e: *delEdges) {
// print removed edges
// std::cout << e->adjSource() << std::endl;
G.delEdge(e);
}
//for (edge e: *delEdges) {
// // print removed edges
// // std::cout << e->adjSource() << std::endl;
// G.delEdge(e);
//}
// write processed graph to new gml file
// GraphIO::write(G, "output.gml", GraphIO::writeGML);
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;
// std::cout << 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;
return 0;

View File

@ -27,20 +27,19 @@ int main(int argc, char* argv[])
NodeArray<int> numbering(G);
int num = computeSTNumbering(G, numbering, nullptr, nullptr, true);
computeSTNumbering(G, numbering, nullptr, nullptr, true);
OGDF_ASSERT(num == G.numberOfNodes());
// print after input
// graphPrinter(G);
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;
// 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;
// separator for planarization
// <-------------->
// PQ implementation to make planar subgraph
std::cout << "start planarization" << std::endl;
List<edge> *delEdges = new List<edge>; // empty list
PlanarSubgraphFast<int> psf;
@ -50,24 +49,25 @@ int main(int argc, char* argv[])
mps.call(G, *delEdges);
std::cout << "Edges removed:" << delEdges->size() << std::endl;
// print edges removed
std::cout << delEdges->size() << std::endl;
// delete removed edges
for (edge e: *delEdges) {
// print removed edges
// std::cout << e->adjSource() << std::endl;
G.delEdge(e);
}
// for (edge e: *delEdges) {
// // print removed edges
// // std::cout << e->adjSource() << std::endl;
// G.delEdge(e);
// }
// write processed graph to new gml file
// GraphIO::write(G, "output.gml", GraphIO::writeGML);
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;
// 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;
return 0;

View File

@ -0,0 +1,29 @@
/* This code only tests the graph for planarity
*
*/
#include <ogdf/fileformats/GraphIO.h>
#include <ogdf/basic/extended_graph_alg.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;
}
// print after input
// graphPrinter(G);
std::cout << ogdf::isPlanar(G) << std::endl;
return 0;
}

296
notebooks/statistics.ipynb Normal file

File diff suppressed because one or more lines are too long