Given a directed weighted graph on n vertices (1..n), an m-by-3 matrix edges = [u, v, w] (directed edge u -> v with integer weight w, possibly negative or parallel), and a designated root vertex root in 1..n:
Find a minimum-cost directed spanning tree rooted at root — a subset of n - 1 edges such that every vertex in 1..n is reachable from root along directed paths.
Return:
- total_cost: the exact minimum total weight (or Inf if unreachable).
- arb_edges: a row vector of n - 1 distinct edge row indices (into edges) forming that optimal directed spanning tree (or [] if unreachable).
Constraints:
- n <= 180, m <= 2500.

Solution Stats

2 Solutions

1 Solvers

Last Solution submitted on Nov 30, 2026

Last 200 Solutions

Solution Comments

Show comments
Loading...

Problem Recent Solvers1

Suggested Problems

More from this Author31

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!