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
Coding & Algorithms
Software Engineer
Wiz
December 9, 2025
Software Engineer
Live Technical Session
Coding & Algorithms
Medium

9

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
Graph traversal with weighted edges
Risk propagation algorithms
BFS with priority queue
Convergence in iterative algorithms
Diminishing returns modeling
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. 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 Problems
Sample 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
  1. 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...

Submit Your Answer
Markdown supported

Related Questions