How this calculation works
Find a minimum-cost directed connection from a root to all required terminals in a small nonnegative weighted graph. Optional intermediate vertices may be used to share routes. The calculation enumerates arc subsets within a strict size bound, then extracts a rooted witness. It is a directed Steiner problem, not separate shortest paths to each terminal.
Minimize selected arc cost subject to a root-to-terminal directed path for every required terminal.A worked example
Sharing arc 0→1 lets routes to terminals two and three use total cost 1+1+1=3. Direct separate arcs cost six. Vertex four is optional and omitted; requiring a spanning arborescence would add its cost-nine arc.
Good to know
≤8 vertices and 14 nonnegative arcs; exhaustive edge subsets. Returns a rooted tree witness after removing irrelevant edges. Infeasibility is explicit. Not a scalable approximation algorithm or a requirement to span all optional vertices.
Why separate shortest paths can cost more
Two terminal routes may share an initial section from the root. Paying for that section once can make a joint network cheaper than choosing each terminal’s route independently.
Conversely, one shortest path can block no route here because capacities are absent. The optimization minimizes the cost of selected directed arcs, not the sum of each terminal’s travel distance. Shared edges are paid once regardless of how many terminal paths traverse them.
Terminals are a selected subset; optional vertices can be omitted, unlike spanning every declared vertex. The Graph modular decomposition calculator with strong modules offers a complementary calculation under its own stated assumptions.
Direction and terminal conventions
Every terminal must be reachable from the root by following selected arcs in their stated direction. Reaching the root from a terminal is irrelevant. Nonterminal vertices are permitted as Steiner junctions and do not need to be listed as requirements.
A terminal equal to the root is already reached. Nonnegative costs ensure surplus cycles can be discarded without improving the objective through negative-cost circulation. Negative arc costs would require different handling and are not supported.
Worked example and mathematical rule
Sharing arc 0→1 lets routes to terminals two and three use total cost 1+1+1=3. Direct separate arcs cost six. Vertex four is optional and omitted; requiring a spanning arborescence would add its cost-nine arc.
Minimize selected arc cost subject to a root-to-terminal directed path for every required terminal.
Exact search within a small arc budget
The tool enumerates selected-arc subsets and tests root-to-terminal reachability. This establishes an exact optimum for a completed supported instance.
The cost is exponential in the number of arcs, which is why the interface places a much smaller bound on edges than a shortest-path calculator. A general large-network Steiner solver uses more sophisticated optimization. Do not extrapolate this page’s convenient runtime on a small example to a dense real-world network.
From a reachable subgraph to a tree witness
A feasible selected subgraph may contain unnecessary arcs. The implementation extracts a rooted discovery structure and prunes optional leaves that lead to no required terminal. With nonnegative weights this does not worsen cost.
The retained arcs demonstrate directed reachability and show where paths share infrastructure. Several different minimum-cost witnesses can exist, especially when zero-cost arcs are present. Search order may select one without asserting it is structurally unique.
Infeasible networks and isolated terminals
If even the full directed graph cannot reach a terminal, no feasible subset can do so. A negative result therefore concerns the supplied arc directions and terminal list, not merely weak connectivity of the drawing.
Check labels carefully when a graph looks connected but fails. An undirected physical connection must be represented by the intended directed arcs if both directions are genuinely available; those arcs still have their own cost semantics in this directed model.
What the objective leaves out
There are no capacity, redundancy, delay, reliability or flow-demand constraints. A cheap single connecting tree may be fragile or congested in practice. Arc cost is additive and does not change with traffic.
Before applying the result operationally, ask whether those omitted features matter. For verification, add the returned arc costs and independently traverse from the root to every terminal. Compare that witness cost to the reported minimum rather than to a sum of terminal distances.
A few questions, answered
Are intermediate nonterminals allowed?
Yes. They are the Steiner vertices that can make shared routes cheaper.
Are shared arcs paid several times?
No. Each selected arc contributes its cost once.
Can I use negative arc costs?
No. This bounded exact implementation requires nonnegative costs.
Does a connected undirected drawing guarantee feasibility?
No. Every required terminal needs a directed route from the selected root.