Skip to main content

Module graph

Module graph 

Source
Expand description

Graph algorithms

This module provides graph algorithms for optimization:

  • dijkstra - Shortest path algorithms
  • flow - Max flow and min cost flow
  • matching - Graph matching algorithms

§Graph Representation

We use petgraph for the underlying graph structure, with wrapper types for optimization-specific operations.

§Example: Max Flow

use converge_optimization::graph::flow::{FlowNetwork, max_flow};

let mut net = FlowNetwork::new(4);
net.add_edge_with_capacity(0, 1, 10);
net.add_edge_with_capacity(0, 2, 10);
net.add_edge_with_capacity(1, 3, 10);
net.add_edge_with_capacity(2, 3, 10);

let result = max_flow(&net, 0, 3).unwrap();
assert_eq!(result.max_flow, 20);

Re-exports§

pub use flow::FlowNetwork;
pub use flow::MaxFlowResult;
pub use flow::MinCostFlowProblem;
pub use flow::MinCostFlowResult;
pub use flow::max_flow;
pub use flow::min_cost_flow;

Modules§

dijkstra
Dijkstra’s shortest path algorithm
flow
Network flow algorithms
matching
Graph matching algorithms

Structs§

FlowEdge
Edge with capacity and cost for flow problems
Path
Path in a graph

Type Aliases§

EdgeId
Edge identifier
Graph
A directed graph with node and edge weights
NodeId
Node identifier