Skip to content

Commit

Permalink
seems to be working
Browse files Browse the repository at this point in the history
  • Loading branch information
stanleygu committed Feb 25, 2013
1 parent 24e3c88 commit f9ab33c
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions HW3.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ var minCut = function(g) {
for (var prop in g) {
var elements = g[prop];
var ind = elements.indexOf(randEdge[1]);
if (~ind) {
while (~ind) {
elements[ind] = parseInt(randEdge[0], 10);
ind = elements.indexOf(randEdge[1]);
}
}
// remove self loops
Expand All @@ -65,9 +66,9 @@ var minCut = function(g) {
ind = elements.indexOf(parseInt(prop, 10));
}
}

console.log(g);
// call minCut again
//minCut(g);
minCut(g);
}
};

Expand All @@ -78,21 +79,16 @@ console.log(minCut(baseCase)); // base case
var randomEdge = function (g) {
// generate edge list
var edgeList = [];

for (var prop in g) {
var element = g[prop];
element.forEach(function (element, index, array){
edgeList.push([prop, element]); // adding to edge list
});
}

// pick random edge
var iRandomEdge = Math.floor(Math.random()*edgeList.length);
return edgeList[iRandomEdge];
};

console.log(randomEdge(baseCase))

console.log(testGraph)
minCut(testGraph)
console.log(testGraph)

0 comments on commit f9ab33c

Please sign in to comment.