A Salesforce administrator is working on optimizing data collection for Opportunity records across multiple branches.
The branches follow a hierarchical structure, forming a tree with n nodes labeled from 0 to n-1. Each node represents a branch, and an array opportunityData of size n indicates whether a branch contains important Opportunity data. Specifically, opportunityData[i] = 1 if branch i holds relevant data and 0 otherwise.
To gather all Opportunity data, the admin must navigate through the branches using bidirectional paths (edges), which can be traversed multiple times if necessary. The goal is to minimize the total distance traveled, measured by the number of edges crossed. Additionally, any data within a radius of 2 edges from a branch can be collected. For system consistency, the retrieval process must start and end at the same branch.
Determine the minimum number of edges the admin needs to traverse to collect all Opportunity data.
Example1:

Example2:

Salesforce • Pending