computeInteractions method
Computes pairwise interaction strengths between active concepts.
Two concepts interact strongly when they share related concept IDs or
when they co-occur in the workspace. Returns a map of
"conceptId1|conceptId2" → strength.
Implementation
Map<String, double> computeInteractions() {
final interactions = <String, double>{};
final active = getActiveWorkspace();
for (var i = 0; i < active.length; i++) {
for (var j = i + 1; j < active.length; j++) {
final a = active[i];
final b = active[j];
// Co-occurrence base strength
var strength = (a.activationLevel + b.activationLevel) / 2;
// Boost if they are explicitly related
if (a.relatedConceptIds.contains(b.id) ||
b.relatedConceptIds.contains(a.id)) {
strength = math.min(1.0, strength + 0.25);
}
// Semantic similarity via embedding if available
if (a.embedding != null && b.embedding != null) {
final sim = a.embedding!.cosineSimilarity(b.embedding!);
strength = math.min(1.0, strength + sim * 0.15);
}
interactions['${a.id}|${b.id}'] = strength;
}
}
return interactions;
}