Solution using Prim's Algorithm
Code

# Code
```python3 []
class Solution:
    def minMaxWeight(self, n: int, edges: List[List[int]], threshold: int) -> int:
        # use Prim's algorithm to find the MST
        # invert the graph and use priority queues to store the edges that come out of the visited nodes
        # sort by edge weight

        # first invert the graph
        adj = [[] for i in range(n)]
        for edge in edges:
            adj[edge[1]].append((edge[2], edge[0]))
  
        # visited set to keep track of vertices already in the MST
        visited = set()
        #begin with 0
        visited.add(0)
        # add all edges from zero to pq
        pq = []
        heapify(pq)
        self.addEdges(adj, 0, pq, visited)
        max_weight = 0
        # add new edges until all vertices are added or there are no more possible edges
        while len(visited) < n and pq:
            # pop out the lowest weight edge and add the new vertex
            edge = heappop(pq)

            # if the vertex is visited, skip
            if edge[1] in visited:
                continue
            
            visited.add(edge[1])
            max_weight = max(max_weight, edge[0])
            # add all outgoing edges from the new vertex
            self.addEdges(adj, edge[1], pq, visited)
        if len(visited) < n:
            return -1
        return max_weight

    def addEdges(self, adj, node, pq, visited):
        for edge in adj[node]:
            if edge[1] not in visited:
                heappush(pq, (edge[0], edge[1]))


```
['Python3']