Skip to content
Merged
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
14 changes: 7 additions & 7 deletions src/graph/investment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type InvestmentGraph = Graph<InvestmentSet, GraphEdge, Directed>;
///
/// 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.
Expand Down Expand Up @@ -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,
Expand All @@ -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) => {
Expand All @@ -80,11 +80,11 @@ fn init_investment_graph_for_year(
kind,
CommodityType::ServiceDemand | CommodityType::SupplyEqualsDemand
)
.then_some(GraphNode::Commodity(cid.clone()))
.then(|| GraphNode::Commodity(cid.clone()))
}
_ => None,
},
|_, e| matches!(e, GraphEdge::Primary(_)).then_some(e.clone()),
|_, e| Some(e.clone()),
);
Comment on lines 75 to 88

// Add nodes to the combined graph
Expand Down
Loading