Implement progress tracking for clique finding

Introduces a mechanism for tracking progress during clique finding operations. This includes implementing a progress bar state management system, handling visibility checks, and integrating progress reporting into the clique finding logic and result processing.
This commit is contained in:
Eric Coissac committed 2026-11-03 09:26:29 +11:00
1 parent db2b398dd0
commit 1d692d7e0b
5 files changed
+141 -1

No files matched your search

+7
View File
@@ -21,6 +21,10 @@ type CliqueOptions struct {
Workers int
// Seed seeds the random vertex orders of the restarts.
Seed int64
// Progress, if set, is called with the size of the best clique each time a
// larger one is found. Calls are serialized and made while a lock is held:
// it must return quickly and must not call FindClique.
Progress func(best int)
}
// CliqueResult is the outcome of FindClique.
@@ -68,6 +72,9 @@ func FindClique(ctx context.Context, n int, filter NeighborFilter, target int, o
mutex.Lock()
if len(clique) > len(best) {
best = append(best[:0], clique...)
if opts.Progress != nil {
opts.Progress(len(best))
}
}
mutex.Unlock()
}