Feat: added graph generation for barabasi-albert and regular
This commit is contained in:
parent
803274cb80
commit
7b875ba141
|
@ -0,0 +1,27 @@
|
||||||
|
#include <ogdf/basic/basic.h>
|
||||||
|
#include <ogdf/basic/Graph.h>
|
||||||
|
#include <ogdf/fileformats/GraphIO.h>
|
||||||
|
#include <ogdf/basic/graph_generators.h>
|
||||||
|
|
||||||
|
using namespace ogdf;
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
int nodeCount = std::stoi(argv[1]);
|
||||||
|
int edgeCount = std::stoi(argv[2]);
|
||||||
|
int copies = std::stoi(argv[3]);
|
||||||
|
int seed = std::stoi(argv[4]);
|
||||||
|
std::string outputFolder = argv[5];
|
||||||
|
|
||||||
|
setSeed(seed);
|
||||||
|
for (int i = 0; i < copies; i++) {
|
||||||
|
Graph G;
|
||||||
|
randomRegularGraph(G, nodeCount, edgeCount);
|
||||||
|
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << outputFolder << "/graphn" << nodeCount << "e" << edgeCount << "s"
|
||||||
|
<< seed << "i" << i << ".gml";
|
||||||
|
std::string s = ss.str();
|
||||||
|
GraphIO::write(G, s, GraphIO::writeGML);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
#include <ogdf/basic/basic.h>
|
||||||
|
#include <ogdf/basic/Graph.h>
|
||||||
|
#include <ogdf/fileformats/GraphIO.h>
|
||||||
|
#include <ogdf/basic/graph_generators.h>
|
||||||
|
|
||||||
|
using namespace ogdf;
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
int nodeCount = std::stoi(argv[1]);
|
||||||
|
int edgeCount = std::stoi(argv[2]);
|
||||||
|
int copies = std::stoi(argv[3]);
|
||||||
|
int seed = std::stoi(argv[4]);
|
||||||
|
std::string outputFolder = argv[5];
|
||||||
|
|
||||||
|
setSeed(seed);
|
||||||
|
for (int i = 0; i < copies; i++) {
|
||||||
|
Graph G;
|
||||||
|
preferentialAttachmentGraph(G, nodeCount, edgeCount);
|
||||||
|
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << outputFolder << "/graphn" << nodeCount << "e" << edgeCount << "s"
|
||||||
|
<< seed << "i" << i << ".gml";
|
||||||
|
std::string s = ss.str();
|
||||||
|
GraphIO::write(G, s, GraphIO::writeGML);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,2 @@
|
||||||
|
100*
|
||||||
|
make_scale_free_graph
|
|
@ -0,0 +1,30 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Define the parameters
|
||||||
|
num_node_range=(100 1000 10000)
|
||||||
|
edge_multiplier_range=(2 3 5 10 20)
|
||||||
|
copies=20
|
||||||
|
seed=41
|
||||||
|
|
||||||
|
max_jobs=2
|
||||||
|
running_jobs=0
|
||||||
|
|
||||||
|
# Loop through different parameters
|
||||||
|
for num_node in "${num_node_range[@]}"; do
|
||||||
|
for edge_multiplier in "${edge_multiplier_range[@]}"; do
|
||||||
|
num_edge=$((num_node * edge_multiplier))
|
||||||
|
output_folder="${num_node}n${num_edge}e"
|
||||||
|
mkdir -p $output_folder
|
||||||
|
|
||||||
|
# Run the program with the parameters
|
||||||
|
echo "run with $num_node nodes and $num_edge edges output to $output_folder"
|
||||||
|
./make_scale_free_graph $num_node $num_edge $copies $seed $output_folder &
|
||||||
|
|
||||||
|
((running_jobs++))
|
||||||
|
|
||||||
|
if ((running_jobs >= max_jobs)); then
|
||||||
|
wait
|
||||||
|
running_jobs=0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
|
@ -0,0 +1,2 @@
|
||||||
|
100*
|
||||||
|
make_regular_graph
|
|
@ -0,0 +1,30 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Define the parameters
|
||||||
|
num_node_range=(100 1000 10000)
|
||||||
|
edge_multiplier_range=(2 3 5 10 20)
|
||||||
|
copies=20
|
||||||
|
seed=41
|
||||||
|
|
||||||
|
max_jobs=2
|
||||||
|
running_jobs=0
|
||||||
|
|
||||||
|
# Loop through different parameters
|
||||||
|
for num_node in "${num_node_range[@]}"; do
|
||||||
|
for edge_multiplier in "${edge_multiplier_range[@]}"; do
|
||||||
|
num_edge=$((num_node * edge_multiplier))
|
||||||
|
output_folder="${num_node}n${num_edge}e"
|
||||||
|
mkdir -p $output_folder
|
||||||
|
|
||||||
|
# Run the program with the parameters
|
||||||
|
echo "run with $num_node nodes and $num_edge edges output to $output_folder"
|
||||||
|
./make_regular_graph $num_node $num_edge $copies $seed $output_folder &
|
||||||
|
|
||||||
|
((running_jobs++))
|
||||||
|
|
||||||
|
if ((running_jobs >= max_jobs)); then
|
||||||
|
wait
|
||||||
|
running_jobs=0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
Loading…
Reference in New Issue