⬅ Previous Topic
Minimum Multiplications to Reach End - Graph BFSVertices | Edges | Source | Output | Description |
---|---|---|---|---|
5 | [(0,1,5), (0,2,4), (1,3,3), (2,1,6), (3,2,-2)] | 0 | [0,5,4,8,INF] | Shortest paths from source 0 to all vertices |
3 | [(0,1,1), (1,2,-1), (2,0,-1)] | 0 | [-1] | Graph contains a negative weight cycle |
4 | [(0,1,1), (0,2,4), (1,2,-2), (2,3,2)] | 0 | [0,1,-1,1] | Graph with negative weights, but no cycle |
2 | [(0,1,3)] | 0 | [0,3] | Simple two-node graph |
1 | [] | 0 | [0] | Graph with only one node |