Record Linkage Part 3 - Full Connected Component
Learn this problemProblem statement
This continues the record-linkage problem. You are given user records and a weighted similarity rule, and must return the full set of records transitively connected to a target.
Inputs: rows (a String[] of "id,name,email,company"), weights (a String[] of "field,weight" over {name, email, company}, summing to 1), threshold, and targetId.
Two records are linked when their weighted field-equality similarity is >= threshold (each matching field contributes its weight). Linkage is transitive: if A links to B and B links to C, then A, B, and C are all in the same group even if A and C are not directly linked.
Return the ids of every record in the same connected component as targetId (i.e. reachable through any chain of links), excluding the target itself, as an int[] sorted in ascending order.
Function
findLinkedComponent(rows: String[], weights: String[], threshold: float, targetId: int) β int[]Examples
Example 1
rows = ["1,Alice,alice@gmail.com,Stripe", "2,Alicia,alice@gmail.com,Stripe", "3,Alice,alice@yahoo.com,Google", "4,Bob,bob@gmail.com,Stripe"]weights = ["name,0.2", "email,0.5", "company,0.3"]threshold = 0.5targetId = 1return = [2]Example 2
rows = ["1,Alice,alice@gmail.com,Stripe", "2,Alicia,alice@gmail.com,Stripe", "3,Bob,bob@yahoo.com,Google", "5,Alicia,carol@outlook.com,Stripe"]weights = ["name,0.2", "email,0.5", "company,0.3"]threshold = 0.5targetId = 1return = [2, 5]Constraints
- Each row is
"id,name,email,company"with an integer id. - Each weight entry is
"field,weight"over {name, email, company}; weights sum to 1. - Similarity = sum of weights of matching fields; records are linked when similarity
>= threshold. - Linkage is transitive (connected components over the similarity graph).
- Return the ascending-sorted
int[]of ids in the target's component, excluding the target.