Algorithms
GraphsOptim
— ModuleGraphsOptim
A package for graph optimization algorithms that rely on mathematical programming.
Flow
GraphsOptim.min_cost_flow
— Functionmin_cost_flow(
+Algorithms · GraphsOptim.jl Algorithms
GraphsOptim
— ModuleGraphsOptim
A package for graph optimization algorithms that rely on mathematical programming.
sourceFlow
GraphsOptim.min_cost_flow
— Functionmin_cost_flow(
g, vertex_demand, edge_cost, edge_min_capacity, edge_max_capacity;
integer, optimizer
-)
Compute a minimum cost flow over a directed graph.
Arguments
g::Graphs.AbstractGraph
: a directed graph G = (V, E)
vertex_demand::AbstractVector
: a vector in Rⱽ
giving the flow requested by each vertex (should be positive for sinks, negative for sources and zero elsewhere)edge_cost::AbstractMatrix
: a vector in Rᴱ
giving the cost of a unit of flow on each edgeedge_min_capacity::AbstractMatrix
: a vector in Rᴱ
giving the minimum flow allowed on each edgeedge_max_capacity::AbstractMatrix
: a vector in Rᴱ
giving the maximum flow allowed on each edge
Keyword arguments
integer::Bool
: whether the flow should be integer-valued or real-valuedoptimizer
: JuMP-compatible solver (default is HiGHS.Optimizer
)
sourceGraphsOptim.min_cost_flow!
— Functionmin_cost_flow!(
+)
Compute a minimum cost flow over a directed graph.
Arguments
g::Graphs.AbstractGraph
: a directed graph G = (V, E)
vertex_demand::AbstractVector
: a vector in Rⱽ
giving the flow requested by each vertex (should be positive for sinks, negative for sources and zero elsewhere)edge_cost::AbstractMatrix
: a vector in Rᴱ
giving the cost of a unit of flow on each edgeedge_min_capacity::AbstractMatrix
: a vector in Rᴱ
giving the minimum flow allowed on each edgeedge_max_capacity::AbstractMatrix
: a vector in Rᴱ
giving the maximum flow allowed on each edge
Keyword arguments
integer::Bool
: whether the flow should be integer-valued or real-valuedoptimizer
: JuMP-compatible solver (default is HiGHS.Optimizer
)
sourceGraphsOptim.min_cost_flow!
— Functionmin_cost_flow!(
model,
g, vertex_demand, edge_cost, edge_min_capacity, edge_max_capacity;
var_name, integer
-)
Modify a JuMP model by adding the variable, constraints and objective necessary to compute a minimum cost flow over a directed graph.
The flow variable will be named var_name
, see min_cost_flow
for details on the other arguments.
sourceWe denote by:
- $f$ the edge flow variable
- $c$ the edge cost
- $a$ and $b$ the min and max edge capacity
- $d$ the vertex demand
The objective function is
\[\min_{f \in \mathbb{R}^E} \sum_{(u, v) \in E} c(u, v) f(u, v)\]
The edge capacity constraint dictates that for all $(u, v) \in E$,
\[a(u, v) \leq f(u, v) \leq b(u, v)\]
The flow conservation constraint with node demand dictates that for all $v \in V$,
\[f^-(v) = d(v) + f^+(v)\]
where the incoming flow $f^-(v)$ and outgoing flow $f^+(v)$ are defined as
\[f^-(v) = \sum_{u \in N^-(v)} f(u, v) \quad \text{and} \quad f^+(v) = \sum_{w \in N^+(v)} f(v, w)\]
Assignment
Work in progress Come back later!
GraphsOptim.min_cost_assignment
— Functionmin_cost_assignment(
+)
Modify a JuMP model by adding the variable, constraints and objective necessary to compute a minimum cost flow over a directed graph.
The flow variable will be named var_name
, see min_cost_flow
for details on the other arguments.
sourceWe denote by:
- $f$ the edge flow variable
- $c$ the edge cost
- $a$ and $b$ the min and max edge capacity
- $d$ the vertex demand
The objective function is
\[\min_{f \in \mathbb{R}^E} \sum_{(u, v) \in E} c(u, v) f(u, v)\]
The edge capacity constraint dictates that for all $(u, v) \in E$,
\[a(u, v) \leq f(u, v) \leq b(u, v)\]
The flow conservation constraint with node demand dictates that for all $v \in V$,
\[f^-(v) = d(v) + f^+(v)\]
where the incoming flow $f^-(v)$ and outgoing flow $f^+(v)$ are defined as
\[f^-(v) = \sum_{u \in N^-(v)} f(u, v) \quad \text{and} \quad f^+(v) = \sum_{w \in N^+(v)} f(v, w)\]
Assignment
Work in progress Come back later!
GraphsOptim.min_cost_assignment
— Functionmin_cost_assignment(
edge_cost;
optimizer
-)
Compute a minimum cost assignment over a bipartite graph.
Arguments
edge_cost::AbstractMatrix
: a matrix in Rᵁˣⱽ
giving the cost of matching u ∈ U
to v ∈ V
Keyword arguments
integer::Bool
: whether the flow should be integer-valued or real-valuedoptimizer
: JuMP-compatible solver (default is HiGHS.Optimizer
)
sourceGraphsOptim.min_cost_assignment!
— Functionmin_cost_assignment!(
+)
Compute a minimum cost assignment over a bipartite graph.
Arguments
edge_cost::AbstractMatrix
: a matrix in Rᵁˣⱽ
giving the cost of matching u ∈ U
to v ∈ V
Keyword arguments
integer::Bool
: whether the flow should be integer-valued or real-valuedoptimizer
: JuMP-compatible solver (default is HiGHS.Optimizer
)
sourceGraphsOptim.min_cost_assignment!
— Functionmin_cost_assignment!(
model,
edge_cost;
var_name, integer
-)
Modify a JuMP model by adding the variable, constraints and objective necessary to compute a minimum cost assignment over a bipartite graph.
The assignment variable will be named var_name
, see min_cost_assignment
for details on the other arguments.
sourceGraph matching
Work in progress Come back later!
GraphsOptim.graph_matching
— Functiongraph_matching(
+)
Modify a JuMP model by adding the variable, constraints and objective necessary to compute a minimum cost assignment over a bipartite graph.
The assignment variable will be named var_name
, see min_cost_assignment
for details on the other arguments.
sourceGraph matching
Work in progress Come back later!
GraphsOptim.graph_matching
— Functiongraph_matching(
algo, A, B;
optimizer, P_init, max_iter, tol,
max_iter_sinkhorn, regularizer
-)
Compute an approximately optimal alignment between two graphs using one of two variants of Frank-Wolfe (FAQ or GOAT)
The output is a tuple that contains:
- the permutation matrix
P
defining the alignment; - the distance between the permuted graphs;
- a boolean indicating if the algorithm converged.
Arguments
algo
: allows dispatch based on the choice of algorithm, either FAQ()
or GOAT()
A
: the adjacency matrix of the first graphB
: the adjacency matrix of the second graph
Keyword arguments
For both algorithms:
optimizer
: JuMP-compatible solver (default is HiGHS.Optimizer
)P_init
: initialization matrix (default value is a flat doubly stochastic matrix).max_iter
: maximum iterations of the Frank-Wolfe method (default value is 30).tol
: tolerance for the convergence (default value is 0.1).
Only for GOAT:
regularization
: penalty coefficient in the Sinkhorn algorithm (default value is 100.0).max_iter_sinkhorn
: maximum iterations of the Sinkhorn algorithm (default value is 500).
References
- FAQ: Algorithm 1 of https://arxiv.org/pdf/2111.05366.pdf
- GOAT: Algorithm 3 of https://arxiv.org/pdf/2111.05366.pdf
sourceGraphsOptim.graph_matching_step_size
— Functiongraph_matching_step_size(A, B, P, Q)
Given the adjacency matrices A
and B
, the doubly stochastic matrix P
and the direction matrix Q
, return the step size of the Frank-Wolfe method for graph matching algorithms.
sourceUtils
GraphsOptim.is_binary
— Functionis_binary(x)
Check if a value is equal to 0 or 1 of its type.
sourceGraphsOptim.is_square
— Functionis_square(M)
Check if a matrix is square.
sourceGraphsOptim.is_stochastic
— Functionis_stochastic(S)
Check if a matrix is row-stochastic.
sourceGraphsOptim.is_doubly_stochastic
— Functionis_doubly_stochastic(D)
Check if a matrix is row- and column-stochastic.
sourceGraphsOptim.is_permutation_matrix
— Functionis_permutation_matrix(P)
Check if a matrix is a permutation matrix.
sourceGraphsOptim.flat_doubly_stochastic
— Functionflat_doubly_stochastic(n)
Return the barycenter of doubly stochastic matrices J = 𝟏 * 𝟏ᵀ / n
.
sourceSettings
This document was generated with Documenter.jl version 1.0.1 on Monday 25 September 2023. Using Julia version 1.9.3.
+)
Compute an approximately optimal alignment between two graphs using one of two variants of Frank-Wolfe (FAQ or GOAT)
The output is a tuple that contains:
- the permutation matrix
P
defining the alignment; - the distance between the permuted graphs;
- a boolean indicating if the algorithm converged.
Arguments
algo
: allows dispatch based on the choice of algorithm, eitherFAQ()
orGOAT()
A
: the adjacency matrix of the first graphB
: the adjacency matrix of the second graph
Keyword arguments
For both algorithms:
optimizer
: JuMP-compatible solver (default isHiGHS.Optimizer
)P_init
: initialization matrix (default value is a flat doubly stochastic matrix).max_iter
: maximum iterations of the Frank-Wolfe method (default value is 30).tol
: tolerance for the convergence (default value is 0.1).
Only for GOAT:
regularization
: penalty coefficient in the Sinkhorn algorithm (default value is 100.0).max_iter_sinkhorn
: maximum iterations of the Sinkhorn algorithm (default value is 500).
References
- FAQ: Algorithm 1 of https://arxiv.org/pdf/2111.05366.pdf
- GOAT: Algorithm 3 of https://arxiv.org/pdf/2111.05366.pdf
GraphsOptim.graph_matching_step_size
— Functiongraph_matching_step_size(A, B, P, Q)
Given the adjacency matrices A
and B
, the doubly stochastic matrix P
and the direction matrix Q
, return the step size of the Frank-Wolfe method for graph matching algorithms.
Utils
GraphsOptim.is_binary
— Functionis_binary(x)
Check if a value is equal to 0 or 1 of its type.
GraphsOptim.is_square
— Functionis_square(M)
Check if a matrix is square.
GraphsOptim.is_stochastic
— Functionis_stochastic(S)
Check if a matrix is row-stochastic.
GraphsOptim.is_doubly_stochastic
— Functionis_doubly_stochastic(D)
Check if a matrix is row- and column-stochastic.
GraphsOptim.is_permutation_matrix
— Functionis_permutation_matrix(P)
Check if a matrix is a permutation matrix.
GraphsOptim.flat_doubly_stochastic
— Functionflat_doubly_stochastic(n)
Return the barycenter of doubly stochastic matrices J = 𝟏 * 𝟏ᵀ / n
.