Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
make-github-pseudonymous-again committed Feb 11, 2018
1 parent 87b5edf commit 40b1874
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 38 deletions.
34 changes: 13 additions & 21 deletions lib/maxback/_smallcuts.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 6 additions & 7 deletions lib/maxback/maxback.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lib/maxback/mb.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 3 additions & 6 deletions src/maxback/_smallcuts.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,10 @@ export default function* _smallcuts ( G ) {
while ( H.size >= 2 ) {

const ordering = list(_order(H));
const x = ordering[ordering.length-2][0];
const y = ordering[ordering.length-1][0];
const [ x ] = ordering[ordering.length-2];
const [ y , cutsize ] = ordering[ordering.length-1];

const U = new Set(chain(map( ([u,_]) => id.get(u) , head(ordering,-1) ) ));
const V = new Set(id.get(y));

yield { 'partition' : [ U , V ] , 'size' : ordering[ordering.length-1][1] } ;
yield [ new Set(id.get(y)) , cutsize ] ;

id.set(x, id.get(x).concat(id.get(y)));

Expand Down
2 changes: 1 addition & 1 deletion src/maxback/maxback.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ import outgoingedges from '../outgoingedges';
*/
export default function maxback ( edges ) {
const G = adj( edges ) ;
const { partition : [ U , _ ] } = mb( G ) ;
const [ U ] = mb( G ) ;
return outgoingedges( G , U ) ;
}
2 changes: 1 addition & 1 deletion src/maxback/mb.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import { attr , increasing } from '@aureooms/js-compare' ;
import _smallcuts from './_smallcuts' ;

export default function mb ( G ) {
return min( attr( increasing , 'size' ) , _smallcuts(G) , undefined ) ;
return min( attr( increasing , 1 ) , _smallcuts(G) , undefined ) ;
}

0 comments on commit 40b1874

Please sign in to comment.