human
What is a Python program to find the minimum (True) or maximum (False) spanning tree given the following:
Complete the below
def kruskal_mst_edges(G, minimum, weight='weight', keys=True, data=True, ignore_nan=False):

    ''''Iterate over edges of a Kruskal\'s algorithm min/max spanning tree.
    Parameters
    G : NetworkX Graph
    The graph holding the tree of interest.
    minimum : bool (default: True)
    Find the minimum (True) or maximum (False) spanning tree.
    weight : string (default: \'weight\')
    The name of the edge attribute holding the edge weights.
    keys : bool (default: True)
    If `G` is a multigraph, `keys` controls whether edge keys ar yielded.
    Otherwise `keys` is ignored.
    data : bool (default: True)
    Flag for whether to yield edge attribute dicts.
    If True, yield edges `(u, v, d)`, where `d` is the attribute dict.
    If False, yield edges `(u, v)`.
    ignore_nan : bool (default: False)
    If a NaN is found as an edge weight normally an exception is raised.
    If `ignore_nan is True` then that edge is ignored instead.'
    '''
assistant
#Here is Python program to find the minimum (True) or maximum (False) spanning tree.
    subtrees = UnionFind()
    if G.is_multigraph():
        edges = G.edges(keys=True, data=True)
        def filter_nan_edges(edges=edges, weight=weight):
            sign = (1 if minimum else (-1))
            for (u, v, k, d) in edges:
                wt = (d.get(weight, 1) * sign)
                if isnan(wt):
                    if ignore_nan:
                        continue
                    msg = 'NaN    found    as    an    edge    weight.    Edge    %s'
                    raise ValueError((msg % ((u, v, f, k, d),)))
                (yield (wt, u, v, k, d))
    else:
        edges = G.edges(data=True)
        def filter_nan_edges(edges=edges, weight=weight):
            sign = (1 if minimum else (-1))
            for (u, v, d) in edges:
                wt = (d.get(weight, 1) * sign)
                if isnan(wt):
                    if ignore_nan:
                        continue
                    msg = 'NaN    found    as    an    edge    weight.    Edge    %s'
                    raise ValueError((msg % ((u, v, d),)))
                (yield (wt, u, v, d))
    edges = sorted(filter_nan_edges(), key=itemgetter(0))
    if G.is_multigraph():
        for (wt, u, v, k, d) in edges:
            if (subtrees[u] != subtrees[v]):
                if keys:
                    if data:
                        (yield (u, v, k, d))
                    else:
                        (yield (u, v, k))
                elif data:
                    (yield (u, v, d))
                else:
                    (yield (u, v))
                subtrees.union(u, v)
    else:
        for (wt, u, v, d) in edges:
            if (subtrees[u] != subtrees[v]):
                if data:
                    (yield (u, v, d))
                else:
                    (yield (u, v))
                subtrees.union(u, v)