Suppose there is a connected undirected graph $V$ with $m$ edges and there are $n$ queries that what is the maximum number of connected vertices using edge no greater than $a_i$. We can assume that $n=O(m)$.
My thoughts is that running DFS $n$ times which takes $O(nm)=O(m^2)$ time. Is there a more efficient algorithm, e.g. runs in $O(m\log m)$ time?
P.S. $V$ is also a weighted graph and $a_i$ means weight.
I'm not entirely clear on what the question is, but if you want to know the size of the largest component using only the $k$ cheapest edges for each $k$, you can sort the edges by cost and then add edges one by one starting from the empty graph, using a union-find structure to keep track of the components. This is $O(m\log m)$.