| Crates.io | ade-graph-generators |
| lib.rs | ade-graph-generators |
| version | 0.1.0 |
| created_at | 2025-08-26 06:09:21.500024+00 |
| updated_at | 2025-08-26 06:09:21.500024+00 |
| description | Functions for generating various types of graph data, including complete and random graphs. |
| homepage | https://github.com/riccardoscalco/ade |
| repository | https://github.com/riccardoscalco/ade |
| max_upload_size | |
| id | 1810570 |
| size | 22,684 |
ade-graph-generators provides functions for generating complete and random graphs. These utilities are particularly useful for testing and benchmarking graph algorithms.
Add this to your Cargo.toml:
[dependencies]
ade-graph-generators = "0.1.0"
This example demonstrates how to use the complete_graph_data function to generate nodes and edges for a complete directed graph. The output is meant to be used as input for the build_graph function.
use ade_graph_generators::complete_graph_data;
fn main() {
// Generate data for a complete graph with 4 nodes.
// In a complete graph, every pair of distinct vertices is connected by a unique edge.
let n = 4;
let (nodes, edges) = complete_graph_data(n);
// The nodes will be [0, 1, 2, 3].
println!("Generated nodes: {:?}", nodes);
assert_eq!(nodes, vec![0, 1, 2, 3]);
// The edges will include all possible directed connections between distinct nodes.
// For n=4, there will be n * (n - 1) = 4 * 3 = 12 edges.
println!("Generated edges: {:?}", edges);
assert_eq!(edges.len(), n * (n - 1));
// Example check for one of the edges (e.g., from node 0 to node 1)
assert!(edges.contains(&(0, 1)));
// Example check for another edge
assert!(edges.contains(&(1, 0)));
}
The complete documentation is available on docs.rs.
Licensed under either of
at your option.