Implement a Graph-Based Risk Score Propagation
Last updated: December 9, 2025
Quick Overview
Given a security graph with weighted nodes and edges, implement an algorithm that propagates risk scores from high-risk nodes to connected nodes, accounting for edge weights and diminishing returns over distance.
Wiz
December 9, 20259
10
4,103 solved
Given a security graph with weighted nodes and edges, implement an algorithm that propagates risk scores from high-risk nodes to connected nodes, accounting for edge weights and diminishing returns over distance.
Risk score propagation is a core algorithm at Wiz. When a critical vulnerability is discovered on a node, connected nodes inherit some of that risk based on their relationship. A database directly accessible from a compromised VM inherits more risk than one separated by multiple network hops. This tests your ability to implement graph algorithms with practical constraints.
What the Interviewer Expects
- Implement a BFS-based propagation with decay factor
- Handle cycles without infinite loops
- Support different edge weight semantics
- Produce a final risk score for every reachable node
- Optimize for large graphs
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you handle negative risk (a firewall reducing risk for nodes behind it)?
- Can you implement incremental updates when a single node's risk changes?
- How would you parallelize this for a graph with millions of nodes?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Problem Analysis
This problem is a graph traversal problem where we need to propagate risk scores through a weighted graph. The specific pattern that applies here is a modified BFS (Breadth-First Search) using a prior...
Approach
- Initialize Data Structures: Create a priority queue to store nodes along with their risk scores (using a tuple of (risk_score, node)). Also, maintain a dictionary to track the highest risk scor...