@@ -38,12 +38,12 @@ public void computeBoruvka(final Queue<ParComponent> nodesLoaded,
3838
3939 while ((n = nodesLoaded .poll ()) != null ) {
4040
41- // Wait for resource to become unlocked
41+ // Check if node n is available
4242 if (! n .lock .tryLock ()) {
4343 continue ;
4444 }
4545
46- // Node n has already been collapsed
46+ // Check if node n has already been collapsed
4747 if (n .isDead ) {
4848 n .lock .unlock ();
4949 continue ;
@@ -52,39 +52,43 @@ public void computeBoruvka(final Queue<ParComponent> nodesLoaded,
5252 // Retrieve n's edge with minimal weight
5353 final Edge <ParComponent > e = n .getMinEdge ();
5454
55- // If no further node available, call setSolution
55+ // If no further node is available, the graph has been
56+ // contracted to a single node and the final solution can be set
5657 if (e == null ) {
5758 solution .setSolution (n );
58- break ; // Contracted graph to a single node
59+ break ;
5960 }
6061
6162 final ParComponent other = e .getOther (n );
6263
64+ // Check if node other is available
6365 if (! other .lock .tryLock ()) {
6466 n .lock .unlock ();
6567 nodesLoaded .add (n );
6668 continue ;
6769 }
6870
71+ // Check if node other has already been collapsed
6972 if (other .isDead ) {
7073 other .lock .unlock ();
7174 n .lock .unlock ();
7275 nodesLoaded .add (n );
7376 continue ;
7477 }
7578
79+ // Mark other node as collapsed
7680 other .isDead = true ;
7781
7882 // Merge node other into n
7983 n .merge (other , e .weight ());
8084
85+ // Release locks
8186 n .lock .unlock ();
8287 other .lock .unlock ();
8388
8489 // Add newly merged n back into nodesLoaded
8590 nodesLoaded .add (n );
8691 }
87-
8892 }
8993
9094 /**
0 commit comments