Optimization: principles and algorithms, by Michel Bierlaire
nodeDivergence.m
Go to the documentation of this file.
1 %> \file
2 %> Compute the divergence of a flow vector (Definition 21.13 of \cite Bier15-book)
3 %>
4 %> @note Tested with \ref runDivergence.m
5 %> @note Called by \ref flowDecomposition
6 %>
7 %> @author Michel Bierlaire
8 %> @date Sun Mar 29 17:30:04 2015
9 %> @ingroup Algorithms
10 %> @ingroup chap21
11
12 %> Compute the divergence of a flow vector
13 %> @param adj adjacency matrix of the network
14 %> @param flow flow vector (number of entries should be equal to the number of non zero entries of the adjacency matrix)
15 %> @return divergence of eachnode
16 function diverg = nodeDivergence(adj,flow)
17  nnodes = rows(adj) ;
18  if (columns(adj) != nnodes)
19  error("Adjacency matrix must be square") ;
20  endif
21
22  diverg = zeros(nnodes, 1) ;
23  for i = 1:nnodes
24  for j = 1:nnodes
25  if (adj(i,j) != 0)
26  diverg(i) += flow(adj(i,j)) ;
27  diverg(j) -= flow(adj(i,j)) ;
28  endif
29  endfor
30  endfor
31 endfunction
function nodeDivergence(in adj, in flow)
Compute the divergence of a flow vector.
function flowDecomposition(in adj, in flow)
Decompose a flow vector into simple path flows.
Copyright 2015-2016 Michel Bierlaire