From 106bc4367ca789b83b03a03a1be8565bdffdb099 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tomasz=20P=C3=B3=C5=82grabia?=
 <tomasz.polgrabia@protonmail.com>
Date: Sat, 5 Mar 2022 17:38:59 +0100
Subject: [PATCH] Adding small refactorings

---
 2022/03/algorithms/maxflow1.js | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/2022/03/algorithms/maxflow1.js b/2022/03/algorithms/maxflow1.js
index 353b5da..ae29f73 100644
--- a/2022/03/algorithms/maxflow1.js
+++ b/2022/03/algorithms/maxflow1.js
@@ -84,24 +84,22 @@ function findMaximumFlow(graph) {
 	console.log('C weights', c);
 
 	// let's find increasing flow path
-	let p, fl;
+	let result
 	do {
-		let {path, flow} = increasingFlowPath(c, m[graph.source], m[graph.target]);
-		p = path;
-		fl = flow;
-		console.log(`Increasing flow ${flow} path ${path}`);	
-		if (path) {
+		result = increasingFlowPath(c, m[graph.source], m[graph.target]);
+		console.log(`Increasing flow ${result.flow} path ${result.path}`);	
+		if (result.flow) {
 			// new increasing flow path
 			// f increase
 			// c decrease
 
-			for (let i = 1; i < path.length; i++) {
-				c[path[i-1]][path[i]] -= flow;
-				f[path[i-1]][path[i]] += flow;
+			for (let i = 1; i < result.path.length; i++) {
+				c[result.path[i-1]][result.path[i]] -= result.flow;
+				f[result.path[i-1]][result.path[i]] += result.flow;
 			}
 
 		}
-	} while (fl);
+	} while (result.flow);
 
 	console.log(`Flow`, c);