You are given an integer
n
denoting the number of nodes of a weighted directed graph. The nodes are numbered from0
ton - 1
.You are also given a 2D integer array
edges
where \(edges[i] = [from_i, to_i, weight_i]\) denotes that there exists a directed edge from \(from_i\) to \(to_i\) with weight \(weight_i\).Lastly, you are given three distinct integers
src1
,src2
, anddest
denoting three distinct nodes of the graph.Return the minimum weight of a subgraph of the graph such that it is possible to reach
dest
from bothsrc1
andsrc2
via a set of edges of this subgraph. In case such a subgraph does not exist, return-1
.A subgraph is a graph whose vertices and edges are subsets of the original graph. The weight of a subgraph is the sum of weights of its constituent edges.