From b755a930afb4ab91143ea03e8433444409d38c1a Mon Sep 17 00:00:00 2001 From: Tom Bland Date: Mon, 22 Jun 2026 11:50:39 +0100 Subject: [PATCH 1/2] Include secondary edges in investment graphs --- src/graph/investment.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/graph/investment.rs b/src/graph/investment.rs index c828009df..c6f02310d 100644 --- a/src/graph/investment.rs +++ b/src/graph/investment.rs @@ -20,7 +20,7 @@ type InvestmentGraph = Graph; /// /// Steps: /// 1. Initialise an `InvestmentGraph` from the set of original `CommodityGraph`s for the given -/// year, filtering to only include SVD/SED commodities and primary edges. `CommodityGraph`s from +/// year, filtering to only include SVD/SED commodities. `CommodityGraph`s from /// all regions are combined into a single `InvestmentGraph`. TODO: at present there can be no /// edges between regions; in future we will want to implement trade as edges between regions, /// but this will have no impact on the following steps. @@ -59,9 +59,9 @@ fn solve_investment_order_for_year( /// Initialise an `InvestmentGraph` for the given year from a set of `CommodityGraph`s /// -/// Commodity graphs for each region are first filtered to only include SVD/SED commodities and -/// primary edges. Each commodity node is then added to a global investment graph as an -/// `InvestmentSet::Single`, with edges preserved from the original commodity graphs. +/// Commodity graphs for each region are first filtered to only include SVD/SED commodities. Each +/// commodity node is then added to a global investment graph as an `InvestmentSet::Single`, with +/// edges preserved from the original commodity graphs. fn init_investment_graph_for_year( graphs: &IndexMap<(RegionID, u32), CommoditiesGraph>, year: u32, @@ -71,7 +71,7 @@ fn init_investment_graph_for_year( // Iterate over the graphs for the given year for ((region_id, _), graph) in graphs.iter().filter(|((_, y), _)| *y == year) { - // Filter the graph to only include SVD/SED commodities and primary edges + // Filter the graph to only include SVD/SED commodities let filtered = graph.filter_map( |_, n| match n { GraphNode::Commodity(cid) => { @@ -84,7 +84,7 @@ fn init_investment_graph_for_year( } _ => None, }, - |_, e| matches!(e, GraphEdge::Primary(_)).then_some(e.clone()), + |_, e| Some(e.clone()), ); // Add nodes to the combined graph From 99530be9d37387202f049c75393558b5cee4541f Mon Sep 17 00:00:00 2001 From: Tom Bland Date: Tue, 23 Jun 2026 11:53:13 +0100 Subject: [PATCH 2/2] Syntax imprevement --- src/graph/investment.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/graph/investment.rs b/src/graph/investment.rs index c6f02310d..06e4fc0d7 100644 --- a/src/graph/investment.rs +++ b/src/graph/investment.rs @@ -80,7 +80,7 @@ fn init_investment_graph_for_year( kind, CommodityType::ServiceDemand | CommodityType::SupplyEqualsDemand ) - .then_some(GraphNode::Commodity(cid.clone())) + .then(|| GraphNode::Commodity(cid.clone())) } _ => None, },