How would you solve a graph-focused data structure and algorithm problem end to end, including edge cases and complexity?
For this SQL exercise, treat the data as a directed graph and start traversal at node 1. Return the shortest reachable path to every node, while safely handling cycles and nodes that cannot be reached.
node_id, node_name, shortest_hops, and path.NULL for unreachable nodes and order by node_id ascending.| Column | Type | Description |
|---|---|---|
| node_idPK | INT | Unique graph node identifier |
| node_name | VARCHAR(100) | Display name for the node |
| Column | Type | Description |
|---|---|---|
| edge_idPK | INT | Unique directed edge identifier |
| from_node_id | INT | Source node of the directed edge |
| to_node_id | INT | Destination node of the directed edge |