Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/KaGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ This is mostly useful for experimental graph generators or when using KaGen to l

auto* params = cmd->add_option_group("Parameters");
add_option_n(params);
params->require_option(1);
add_option_p(params);
params->silent();
}

Expand Down
16 changes: 13 additions & 3 deletions kagen/generators/path/path_directed.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "kagen/generators/path/path_directed.h"
#include "kagen/sampling/hash.hpp"

#ifdef KAGEN_XXHASH_FOUND
#include "kagen/tools/random_permutation.h"
Expand All @@ -17,14 +18,19 @@ PGeneratorConfig PathDirectedFactory::NormalizeParameters(PGeneratorConfig confi
throw ConfigurationError("path permutation requires xxHash, but build was configured without xxHash");
}
#endif // KAGEN_XXHASH_FOUND

if (config.p == 0.0) {
config.p = 1.0;
}
if (config.p > 1.0) {
throw ConfigurationError("edge probability p must be in [0, 1]");
}
return config;
}

PathDirected::PathDirected(const PGeneratorConfig& config, const PEID rank, const PEID size)
: config_(config),
rank_(rank),
size_(size) {}
size_(size), rng_(config) {}

void PathDirected::GenerateEdgeList() {
if (config_.n <= 1) {
Expand Down Expand Up @@ -59,7 +65,11 @@ void PathDirected::GenerateEdgeList() {
}();

if (is_valid) {
PushEdge(i, j);
SInt edge_seed = std::min(i, j) *config_.n + std::max(i, j);
SInt h = sampling::Spooky::hash(config_.seed + edge_seed);
if (rng_.GenerateBinomial(h, 1, config_.p)) {
PushEdge(i, j);
}
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions kagen/generators/path/path_directed.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "kagen/context.h"
#include "kagen/generators/generator.h"
#include "kagen/kagen.h"
#include "kagen/tools/rng_wrapper.h"

namespace kagen {
class PathDirectedFactory : public GeneratorFactory {
Expand All @@ -27,5 +28,7 @@ class PathDirected : public virtual Generator, private EdgeListOnlyGenerator {

PEID rank_;
PEID size_;

RNGWrapper<> rng_;
};
} // namespace kagen
2 changes: 2 additions & 0 deletions tests/path/general_path_generator_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ TEST_P(PathGeneratorTestFixture, path_generation_without_permutation) {

PGeneratorConfig config;
config.n = GetParam();
config.p = 1.0;

PathDirected generator(config, rank, size);
generator.Generate(GraphRepresentation::EDGE_LIST);
Expand All @@ -94,6 +95,7 @@ TEST_P(PathGeneratorTestFixture, path_generation_with_permutation) {

PGeneratorConfig config;
config.n = GetParam();
config.p = 1.0;
config.permute = true;

PathDirected generator(config, rank, size);
Expand Down