@not_implemented_for('directed')
@not_implemented_for('multigraph')
def min_edge_cover(G, matching_algorithm=None):
 if (nx.number_of_isolates(G) > 0):
  raise nx.NetworkXException('Graph has a node with no edge incident on it, so no edge cover exists.')
 if (matching_algorithm is None):
  matching_algorithm = partial(nx.max_weight_matching, maxcardinality=True)
 maximum_matching = matching_algorithm(G)
 min_cover = set(maximum_matching.items())
 uncovered_nodes = (set(G) - {v for (u, v) in min_cover})
 for v in uncovered_nodes:
  u = arbitrary_element(G[v])
  min_cover.add((u, v))
  min_cover.add((v, u))
 return min_cover

@ not_implemented_for ( 'directed' ) @ not_implemented_for ( 'multigraph' ) def min_edge_cover ( G , matching_algorithm = None ) : if ( nx . number_of_isolates ( G ) > 0 ) : raise nx . NetworkXException ( 'Graph has a node with no edge incident on it, so no edge cover exists.' ) if ( matching_algorithm is None ) : matching_algorithm = partial ( nx . max_weight_matching , maxcardinality = True ) maximum_matching = matching_algorithm ( G ) min_cover = set ( maximum_matching . items ( ) ) uncovered_nodes = ( set ( G ) - { v for ( u , v ) in min_cover } ) for v in uncovered_nodes : u = arbitrary_element ( G [ v ] ) min_cover . add ( ( u , v ) ) min_cover . add ( ( v , u ) ) return min_cover
returns a set of edges which constitutes the minimum edge cover of the graph .