- Changed from synchronous to asynchronous updates with randomized node order
- Added maximum iteration limit (100) to prevent infinite loops
- Implemented oscillation detection with early stopping mechanism
- Improved tie-breaking with deterministic sorting
- Added detailed docstring and logging for convergence/oscillation events
- Fixed oscillation detection to properly break out of nested loops
The previous implementation used synchronous updates where all nodes
updated simultaneously, which could cause oscillation in certain graph
structures (e.g., bipartite graphs). This fix ensures the algorithm
always terminates and produces stable community assignments while
maintaining backward compatibility with existing tests.