1
- import { list , map , head , filter , chain } from '@aureooms/js-itertools' ;
1
+ import { list , map } from '@aureooms/js-itertools' ;
2
2
3
- import _order from " ./_order.js" ;
4
- import _contract from " ./_contract.js" ;
3
+ import _order from ' ./_order.js' ;
4
+ import _contract from ' ./_contract.js' ;
5
5
6
6
/**
7
7
* Yields the small cuts of undirected unweighted connected loopless multigraph G.
@@ -10,24 +10,20 @@ import _contract from "./_contract.js" ;
10
10
* @param {Map } G The adjacency list of G.
11
11
* @returns {Iterable } The small cuts of G.
12
12
*/
13
- export default function * _smallcuts ( G ) {
14
-
13
+ export default function * _smallcuts ( G ) {
15
14
let H = G ;
16
15
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 ] ) ;
20
17
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 ] ;
24
22
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
26
24
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
30
26
27
+ H = _contract ( H , list ( map ( ( [ u , _ ] ) => u , ordering ) ) ) ; // Contract all edges between those two vertices
31
28
}
32
-
33
29
}
0 commit comments