code: def main():
      """
      Test. How input works:
      Input consists of different weighted, connected, undirected graphs.
      line 1:
        integers n, m
      lines 2..m+2:
        edge with the format -> node index u, node index v, integer weight
  
      Samples of input:
  
      5 6
      1 2 3
      1 3 8
      2 4 5
      3 4 2
      3 5 4
      4 5 6
  
      3 3
      2 1 20
      3 1 20
      2 3 100
  
      Sum of weights of the optimal paths:
      14, 40
      """
      for size in sys.stdin:
          vertex_count, edge_count = map(int, size.split())
          forest = DisjointSet(edge_count)
          edges = [None] * edge_count  # Create list of size <m>
  
          # Read <m> edges from input
          for i in range(edge_count):
              source, target, weight = map(int, input().split())
              source -= 1  # Convert from 1-indexed to 0-indexed
              target -= 1  # Convert from 1-indexed to 0-indexed
              edges[i] = Edge(source, target, weight)
  
          # After finish input and graph creation, use Kruskal algorithm for MST:
          print(
              "MST weights sum:", kruskal(vertex_count, edges, forest)
          )
  
file_path: keon-algos/algorithms/graph/minimum_spanning_tree.py
imports: import sys
label_desc: Use image node_id 2 for calling a global function with example usage: main() without return types