17template <
typename GraphType = Graph<
int>>
26 using NodeID =
typename GraphType::NodeType;
28 std::constructible_from<NodeID, std::size_t>,
29 "nxpp::complete_graph requires GraphType::NodeType to be constructible from std::size_t because it synthesizes node IDs 0..n-1."
31 for (
size_t i = 0; i < n; ++i) {
32 for (
size_t j = 0; j < n; ++j) {
34 G.add_edge(
static_cast<NodeID
>(i),
static_cast<NodeID
>(j));
41template <
typename GraphType = Graph<
int>>
50 using NodeID =
typename GraphType::NodeType;
52 std::constructible_from<NodeID, std::size_t>,
53 "nxpp::path_graph requires GraphType::NodeType to be constructible from std::size_t because it synthesizes node IDs 0..n-1."
55 for (
size_t i = 0; i < n - 1; ++i) {
56 G.add_edge(
static_cast<NodeID
>(i),
static_cast<NodeID
>(i + 1));
61template <
typename GraphType = Graph<
int>>
72 using NodeID =
typename GraphType::NodeType;
74 std::constructible_from<NodeID, std::size_t>,
75 "nxpp::erdos_renyi_graph requires GraphType::NodeType to be constructible from std::size_t because it synthesizes node IDs 0..n-1."
77 std::mt19937 gen(seed);
78 std::uniform_real_distribution<> dis(0.0, 1.0);
80 for (
size_t i = 0; i < n; ++i) {
81 for (
size_t j = 0; j < (GraphType::is_directed ? n : i); ++j) {
84 G.add_edge(
static_cast<NodeID
>(i),
static_cast<NodeID
>(j));
GraphType path_graph(size_t n)
Builds a simple path on node IDs 0 through n - 1.
Definition generators.hpp:48
GraphType erdos_renyi_graph(size_t n, double p, int seed=42)
Builds an Erdos-Renyi random graph on node IDs 0 through n - 1.
Definition generators.hpp:70
GraphType complete_graph(size_t n)
Builds the complete graph on node IDs 0 through n - 1.
Definition generators.hpp:24
Core graph wrapper, proxy surface, and public alias presets.