1- import { list , map , head , filter , chain } from '@aureooms/js-itertools' ;
1+ import { list , map } from '@aureooms/js-itertools' ;
22
3- import _order from " ./_order.js" ;
4- import _contract from " ./_contract.js" ;
3+ import _order from ' ./_order.js' ;
4+ import _contract from ' ./_contract.js' ;
55
66/**
77 * Yields the small cuts of undirected unweighted connected loopless multigraph G.
@@ -10,24 +10,20 @@ import _contract from "./_contract.js" ;
1010 * @param {Map } G The adjacency list of G.
1111 * @returns {Iterable } The small cuts of G.
1212 */
13- export default function * _smallcuts ( G ) {
14-
13+ export default function * _smallcuts ( G ) {
1514 let H = G ;
1615 const id = new Map ( ) ;
17- for ( const v of G . keys ( ) ) id . set ( v , [ v ] ) ;
18-
19- while ( H . size >= 2 ) {
16+ for ( const v of G . keys ( ) ) id . set ( v , [ v ] ) ;
2017
21- const ordering = list ( _order ( H ) ) ; // compute the max-back order
22- const [ x ] = ordering [ ordering . length - 2 ] ;
23- const [ y , cutsize ] = ordering [ ordering . length - 1 ] ;
18+ while ( H . size >= 2 ) {
19+ const ordering = list ( _order ( H ) ) ; // Compute the max-back order
20+ const [ x ] = ordering [ ordering . length - 2 ] ;
21+ const [ y , cutsize ] = ordering [ ordering . length - 1 ] ;
2422
25- yield [ new Set ( id . get ( y ) ) , cutsize ] ; // yield a small cut with its size
23+ yield [ new Set ( id . get ( y ) ) , cutsize ] ; // Yield a small cut with its size
2624
27- id . set ( x , id . get ( x ) . concat ( id . get ( y ) ) ) ; // associate the last vertex with the penultimate one
28-
29- H = _contract ( H , list ( map ( ( [ u , _ ] ) => u , ordering ) ) ) ; // contract all edges between those two vertices
25+ id . set ( x , id . get ( x ) . concat ( id . get ( y ) ) ) ; // Associate the last vertex with the penultimate one
3026
27+ H = _contract ( H , list ( map ( ( [ u , _ ] ) => u , ordering ) ) ) ; // Contract all edges between those two vertices
3128 }
32-
3329}
0 commit comments