Add or reinforce a relationship edge between two devices.
If an edge already exists for this pair the weight is blended upward
(new = max(0.97, old + increment)) and the occurrence count is bumped.
New reasons are merged into the existing set without duplication.
First device identifier.
Second device identifier (must differ from A).
Human-readable signal that produced this observation.
Strength of this individual observation in [0, 1].
Defaults to 0.3.
Return a snapshot of all edges (for inspection / serialisation).
Return the raw edge between two specific devices, or undefined if none
exists.
Return all devices that share an identity edge with the given device, sorted by descending edge weight.
The device to look up.
An array of RelatedDevice, or an empty array if no edges are known for this device.
Remove edges whose lastSeen is older than maxAgeMs milliseconds.
An edge is considered stale when edge.lastSeen + maxAgeMs <= Date.now(),
so prune(0) removes all edges regardless of age.
Maximum allowed edge staleness in milliseconds.
The number of edges pruned.
Total number of edges currently in the graph.
In-memory identity graph that tracks weighted relationships between distinct device identifiers.
Edges are un-directed but stored with a canonical ordering (
deviceIdA < deviceIdBlexicographically) so each pair is represented by exactly one entry.This implementation is suitable for single-process deployments. For horizontally-scaled environments, edges should be persisted via a shared store and loaded on startup.