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

Network flow utilities: generators, visualization, serialization. More...

#include <fstream>
#include <sstream>
#include <random>
#include <chrono>
#include <iomanip>
#include <tpl_net.H>
#include <tpl_netcost.H>
#include <tpl_dynMapTree.H>
Include dependency graph for net_utils.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Aleph::NetworkGenParams
 Parameters for random network generation. More...
 
struct  Aleph::DotExportOptions
 Options for DOT export. More...
 
struct  Aleph::MaxFlowBenchmarkResult< Flow_Type >
 Result of running a max-flow algorithm. More...
 

Namespaces

namespace  Aleph
 Main namespace for Aleph-w library functions.
 

Functions

template<class Net >
Net Aleph::generate_random_network (const NetworkGenParams &params)
 Generate a random flow network.
 
template<class Net >
Net Aleph::generate_random_network (size_t num_nodes, size_t num_arcs, double min_cap=1.0, double max_cap=100.0, unsigned seed=0)
 Generate a random flow network (convenience overload).
 
template<class Net >
Net Aleph::generate_grid_network (size_t rows, size_t cols, typename Net::Flow_Type capacity, bool bidirectional=true)
 Generate a grid network.
 
template<class Net >
Net Aleph::generate_bipartite_network (size_t left_size, size_t right_size, double edge_prob=0.5, unsigned seed=0)
 Generate a bipartite network for matching.
 
template<class Net >
Net Aleph::generate_layered_network (const std::vector< size_t > &layer_sizes, typename Net::Flow_Type capacity, double edge_prob=0.5, unsigned seed=0)
 Generate a layered network.
 
template<class Net >
void Aleph::export_network_to_dot (const Net &net, const std::string &filename, const DotExportOptions &options=DotExportOptions())
 Export network to DOT format for GraphViz visualization.
 
template<class Net >
std::string Aleph::network_to_dot_string (const Net &net, const DotExportOptions &options=DotExportOptions())
 Generate DOT string for network (instead of file).
 
template<class Net >
void Aleph::export_network_to_json (const Net &net, const std::string &filename)
 Export network to JSON format.
 
template<class Net >
std::string Aleph::network_to_json_string (const Net &net)
 Export network to JSON string.
 
template<class Net >
void Aleph::export_network_to_dimacs (const Net &net, const std::string &filename)
 Export network to DIMACS max-flow format.
 
template<class Net >
Net Aleph::import_network_from_dimacs (const std::string &filename)
 Import network from DIMACS max-flow format.
 
template<class Net , class Algo >
MaxFlowBenchmarkResult< typename Net::Flow_TypeAleph::benchmark_maxflow (Net &net, Algo algo, const std::string &name)
 Run and time a max-flow algorithm.
 
template<typename Flow_Type >
void Aleph::print_benchmark_results (const std::vector< MaxFlowBenchmarkResult< Flow_Type > > &results)
 Print benchmark results.
 

Detailed Description

Network flow utilities: generators, visualization, serialization.

This file provides utility functions for working with network flow graphs:

Network Generators

  • Random networks with various topologies
  • Grid networks (useful for benchmarking)
  • Bipartite matching networks
  • Scale-free networks

Visualization (DOT/GraphViz)

  • Export networks to DOT format
  • Show flow values and capacities
  • Highlight cuts and paths

Serialization

  • JSON export/import
  • DIMACS format support
  • Binary format for large networks

Usage Example

#include <net_utils.H>
// Generate a random network
auto net = generate_random_network<Net_Graph<>>(100, 500, 1, 100);
// Solve max flow
// Export to DOT for visualization
export_network_to_dot(net, "network.dot");
// Export to JSON for persistence
export_network_to_json(net, "network.json");
void export_network_to_dot(const Net &net, const std::string &filename, const DotExportOptions &options=DotExportOptions())
Export network to DOT format for GraphViz visualization.
Definition net_utils.H:462
Net::Flow_Type dinic_maximum_flow(Net &net)
Compute maximum flow using Dinic's algorithm.
void export_network_to_json(const Net &net, const std::string &filename)
Export network to JSON format.
Definition net_utils.H:672
Network flow utilities: generators, visualization, serialization.
See also
tpl_net.H Network flow structures
tpl_maxflow.H Maximum flow algorithms
Author
Leandro Rabindranath León

Definition in file net_utils.H.