Hongjun likes physics, and computing densities is his hobby.
After learning graph theory at school, Hongjun decided to define density on graphs as well. Take an undirected graph whose vertices and edges carry weights, let SumV be the sum of the vertex weights and let SumE be the sum of the edge weights. The density of that graph is SumV/SumE.
For his birthday, Myungwoo gave Hongjun an undirected graph with weights on the vertices and on the edges. Hongjun wants the induced subgraph of largest density.
An induced subgraph G′(V′,E′) of a graph G(V,E) satisfies the following conditions.
- V′⊆V
- The edge joining u and v belongs to E′ if and only if u∈V′, v∈V′, and that edge belongs to E.
- The weights of the vertices and edges of G′ are the same as in G.
- G′ is connected.
An induced subgraph with no edge has SumE=0, so its density is undefined and it is not a candidate.
Help Hongjun and compute the density of the induced subgraph of maximum density.