Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
tpl_net_sup_dem.H File Reference

Supply-demand network flow algorithms. More...

#include <tpl_net.H>
#include <ah-errors.H>
Include dependency graph for tpl_net_sup_dem.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Aleph::Net_Sup_Dem_Node< Node_Info, F_Type >
 Node with supply/demand flow value. More...
 
class  Aleph::Net_Sup_Dem_Graph< NodeT, ArcT >
 Network graph with supply and demand nodes. More...
 

Namespaces

namespace  Aleph
 Main namespace for Aleph-w library functions.
 

Detailed Description

Supply-demand network flow algorithms.

This file provides classes for modeling and analyzing supply-demand networks. In such networks, nodes have supply values (positive = source, negative = sink/demand). The goal is to determine if it's possible to satisfy all demands from the available supplies.

Key Concepts

  • Supply node: A node with positive supply_flow that provides flow
  • Demand node: A node with negative supply_flow that consumes flow
  • Feasibility: Whether all demands can be satisfied from supplies
Example: Basic supply-demand network
using NetSD = Net_Sup_Dem_Graph<Net_Sup_Dem_Node<string, int>,
Net_Arc<Empty_Class, int>>;
NetSD net;
// Create nodes with supply/demand values
auto supplier = net.insert_node("Factory", 100); // supplies 100 units
auto consumer = net.insert_node("Customer", -50); // demands 50 units
auto transit = net.insert_node("Warehouse", 0); // transit node
// Connect nodes with arcs (capacity)
net.insert_arc(supplier, transit, 80);
net.insert_arc(transit, consumer, 60);
// Compute auxiliary network and check feasibility
net.compute_aux_net();
if (net.is_feasible())
cout << "All demands can be satisfied!\n";
Example: Multi-source multi-sink network
NetSD distribution_net;
// Multiple suppliers
auto warehouse1 = distribution_net.insert_node("WH1", 200);
auto warehouse2 = distribution_net.insert_node("WH2", 150);
// Multiple consumers
auto store1 = distribution_net.insert_node("Store1", -120);
auto store2 = distribution_net.insert_node("Store2", -180);
// Distribution hub
auto hub = distribution_net.insert_node("Hub", 0);
// Connect with capacities
distribution_net.insert_arc(warehouse1, hub, 150);
distribution_net.insert_arc(warehouse2, hub, 120);
distribution_net.insert_arc(hub, store1, 120);
distribution_net.insert_arc(hub, store2, 180);
See also
tpl_net.H Base network flow classes
tpl_netcapgraph.H Capacity graph algorithms
Author
Leandro Rabindranath León

Definition in file tpl_net_sup_dem.H.