Network Flow

A={{1,1,0,0,0,0,0,0,0,0},{-1,0,1,-1,1,0,0,0,0,0},{0,0,0,0,-1,1,0,-1,1,0},{0,-1,-1,1,0,-1,1,0,0,0},{0,0,0,0,0,0,-1,1,0,1},{0,0,0,0,0,0,0,0,-1,-1}};A//MatrixForm

capacity={16,13,10,4,12,9,14,7,20,4}

b=gamma{1,0,0,0,0,-1}

Nnodes=6;Nedges=10;

bounds=Table[0≤x[k]≤capacity[[k]],{k,1,Nedges}]

diff=A.Array[x,Nedges]-b

validpath=Table[diff[[k]]==0,{k,1,Nnodes}]

Maximize[{gamma,validpath,bounds},Flatten[{gamma,Array[x,Nedges]}]]