Skip to content
Snippets Groups Projects

Add binary for post-hoc simulations of SIS epidemics

Merged Adam Reichold requested to merge post-hoc-simulation into main
7 files
+ 179
109
Compare changes
  • Side-by-side
  • Inline
Files
7
+ 18
7
@@ -8,12 +8,13 @@ use std::env::args;
use unfolded_graph::{read_aggregated_graph, Time, ZwoHashMap};
const USAGE: &str = "usage: deg <resolution> <until> < <graph.bin> > <histograms.csv>";
const USAGE: &str = "usage: deg <resolution> <until> <weighted> < <graph.bin> > <histograms.csv>";
fn main() {
let mut args = args();
let resolution = args.nth(1).expect(USAGE).parse::<Time>().expect(USAGE);
let until = args.next().expect(USAGE).parse::<Time>().expect(USAGE);
let weighted = args.next().expect(USAGE).parse::<bool>().expect(USAGE);
// Read the aggregated graph up to the given time limit.
let aggregated_graph = read_aggregated_graph(0, resolution, until);
@@ -21,12 +22,22 @@ fn main() {
// Collect two histograms of the outgoing and incoming node degrees.
let mut values = ZwoHashMap::<usize, (usize, usize)>::default();
for (_node, out_deg) in aggregated_graph.out_degrees() {
values.entry(out_deg).or_default().0 += 1;
}
for (_node, in_deg) in aggregated_graph.in_degrees() {
values.entry(in_deg).or_default().1 += 1;
if weighted {
for (_node, out_deg) in aggregated_graph.weighted_out_degrees() {
values.entry(out_deg).or_default().0 += 1;
}
for (_node, in_deg) in aggregated_graph.weighted_in_degrees() {
values.entry(in_deg).or_default().1 += 1;
}
} else {
for (_node, out_deg) in aggregated_graph.out_degrees() {
values.entry(out_deg).or_default().0 += 1;
}
for (_node, in_deg) in aggregated_graph.in_degrees() {
values.entry(in_deg).or_default().1 += 1;
}
}
// Make sure that they are no gaps in the histograms.
Loading