Malware Spread
Implement a prototype service for malware spread control in a network.
There are g_nodes servers in a network and g_edges connections between its nodes. The bi-directional connection connects g_from[i] and g_to[i]. Some of the nodes are infected with malware. They are listed in a binary array, where if malware[i] = 1 node i is infected, and if malware[i] = 0, node i is not infected.
Any infected node infects other non-infected nodes, which are directly connected. This process goes on until no new infections are possible. Exactly 1 node can be removed from the network. Return the index of the node to remove such that the total infected nodes in the remaining network are minimized. If multiple nodes lead to the same minimum result, then return the one with the lowest index.
Complete the function getNodeToRemove in the editor.
getNodeToRemove has the following parameter(s):
int g_nodes: the number of nodesint g_from[n]: one end of the connectionsint g_to[n]: the other end of the connectionsint malware[n]: the affected nodes
Returns
int: the optimal node to remove
1Example 1
2Example 2

Constraints
Limits and guarantees your solution can rely on.
1 ≤ g_nodes ≤ 10^30 ≤ g_edges ≤ min(g_nodes*(g_nodes-1)/2, 10^3)1 ≤ g_from[i], g_to[i] ≤ nmalware[i] = 0 or 1