Skip to content

Commit e07a5e7

Browse files
committed
Merge remote-tracking branch 'origin/main' into fix/752-embed-absolute-paths
2 parents e44ad60 + f8e9351 commit e07a5e7

2 files changed

Lines changed: 5 additions & 73 deletions

File tree

.github/workflows/codegraph-impact.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
name: Codegraph Impact Analysis
22
on: [pull_request]
3+
4+
concurrency:
5+
group: codegraph-impact-${{ github.ref }}
6+
cancel-in-progress: true
7+
38
jobs:
49
impact:
510
runs-on: ubuntu-latest

src/graph/algorithms/leiden/optimiser.ts

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -437,79 +437,6 @@ function boltzmannSelectCandidate(
437437
* (approaches greedy), higher = more exploratory. Determinism is preserved
438438
* via the seeded PRNG — same seed produces the same assignments.
439439
*/
440-
/**
441-
* Collect eligible candidate communities for node `v` during refinement.
442-
* A candidate must: (a) be in the same macro-community, (b) respect the size
443-
* limit, and (c) produce a positive quality gain above GAIN_EPSILON.
444-
* Returns the number of collected candidates written into `scratch`.
445-
*/
446-
function collectRefinementCandidates(
447-
p: Partition,
448-
g: GraphAdapter,
449-
v: number,
450-
touchedCount: number,
451-
macroV: number,
452-
commMacro: Int32Array,
453-
maxSize: number,
454-
opts: NormalizedOptions,
455-
scratch: RefinementScratch,
456-
): number {
457-
let candLen: number = 0;
458-
for (let t = 0; t < touchedCount; t++) {
459-
const c: number = p.getCandidateCommunityAt(t);
460-
if (c === p.nodeCommunity[v]!) continue;
461-
if (commMacro[c]! !== macroV) continue;
462-
if (maxSize < Infinity) {
463-
const nextSize: number = p.getCommunityTotalSize(c) + g.size[v]!;
464-
if (nextSize > maxSize) continue;
465-
}
466-
const gain: number = computeQualityGain(p, v, c, opts);
467-
if (gain > GAIN_EPSILON) {
468-
scratch.candC[candLen] = c;
469-
scratch.candGain[candLen] = gain;
470-
candLen++;
471-
}
472-
}
473-
return candLen;
474-
}
475-
476-
/**
477-
* Boltzmann probabilistic selection from collected candidates (Algorithm 3).
478-
* Returns the chosen community ID, or -1 if the node should stay as singleton.
479-
*
480-
* p(v, C) is proportional to exp(deltaH / theta), with the "stay as singleton"
481-
* option (deltaH = 0) included. For numerical stability, the max gain is
482-
* subtracted before exponentiation.
483-
*/
484-
function boltzmannSelectCandidate(
485-
candLen: number,
486-
theta: number,
487-
rng: () => number,
488-
scratch: RefinementScratch,
489-
): number {
490-
let maxGain: number = 0;
491-
for (let i = 0; i < candLen; i++) {
492-
if (scratch.candGain[i]! > maxGain) maxGain = scratch.candGain[i]!;
493-
}
494-
// "Stay as singleton" weight: exp((0 - maxGain) / theta)
495-
const stayWeight: number = Math.exp((0 - maxGain) / theta);
496-
let totalWeight: number = stayWeight;
497-
for (let i = 0; i < candLen; i++) {
498-
scratch.candWeight[i] = Math.exp((scratch.candGain[i]! - maxGain) / theta);
499-
totalWeight += scratch.candWeight[i]!;
500-
}
501-
502-
const r: number = rng() * totalWeight;
503-
if (r < stayWeight) return -1; // node stays as singleton
504-
505-
let cumulative: number = stayWeight;
506-
for (let i = 0; i < candLen; i++) {
507-
cumulative += scratch.candWeight[i]!;
508-
if (r < cumulative) return scratch.candC[i]!;
509-
}
510-
return scratch.candC[candLen - 1]!; // fallback
511-
}
512-
513440
function refineWithinCoarseCommunities(
514441
g: GraphAdapter,
515442
basePart: Partition,

0 commit comments

Comments
 (0)