Skip to content
Merged
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
500 changes: 497 additions & 3 deletions docs/paper/reductions.typ

Large diffs are not rendered by default.

16 changes: 12 additions & 4 deletions src/models/graph/directed_two_commodity_integral_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ inventory::submit! {
/// whether two integral flow functions f_1, f_2: A -> Z_0^+ exist such that:
/// 1. Joint capacity: f_1(a) + f_2(a) <= c(a) for all a in A
/// 2. Flow conservation: for each commodity i, flow is conserved at every
/// vertex except the four terminals
/// vertex except its own source and sink
/// 3. Requirements: net flow into t_i under f_i is at least R_i
///
/// # Variables
Expand Down Expand Up @@ -191,8 +191,6 @@ impl DirectedTwoCommodityIntegralFlow {
return false;
}
let arcs = self.graph.arcs();
let terminals = [self.source_1, self.sink_1, self.source_2, self.sink_2];

// (1) Joint capacity constraint
for a in 0..m {
let f1 = config[a] as u64;
Expand All @@ -216,8 +214,18 @@ impl DirectedTwoCommodityIntegralFlow {
}

for (commodity, commodity_balances) in balances.iter().enumerate() {
let src = if commodity == 0 {
self.source_1
} else {
self.source_2
};
for (v, &balance) in commodity_balances.iter().enumerate() {
if !terminals.contains(&v) && balance != 0 {
let snk = if commodity == 0 {
self.sink_1
} else {
self.sink_2
};
if v != src && v != snk && balance != 0 {
return false;
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/models/graph/monochromatic_triangle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ impl<G: Graph> MonochromaticTriangle<G> {
&self.triangles
}

/// Get the number of triangles in the graph.
pub fn num_triangles(&self) -> usize {
self.triangles.len()
}

/// Get the ordered edge list.
pub fn edge_list(&self) -> &[(usize, usize)] {
&self.edge_list
Expand Down
12 changes: 12 additions & 0 deletions src/models/misc/feasible_register_assignment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,18 @@ impl FeasibleRegisterAssignment {
self.num_registers
}

/// Count unordered vertex pairs that share a register.
pub fn num_same_register_pairs(&self) -> usize {
let mut counts = vec![0usize; self.num_registers];
for &register in &self.assignment {
counts[register] += 1;
}
counts
.into_iter()
.map(|count| count.saturating_sub(1) * count / 2)
.sum()
}

/// Get the arcs.
pub fn arcs(&self) -> &[(usize, usize)] {
&self.arcs
Expand Down
Loading
Loading