def has_bipartition(G):
    """Check that the graph is labelled with a bipartition

    NetworkX follows the convention that bipartite graphs have their
    vertices labeled with the bipartition. In particular each vertex
    has the 'bipartite' attribute with is either 0 or 1.

    Parameters
    ----------
    G: networkx.Graph

    """
    try:
        for n in G.nodes():
            if not G.nodes[n]['bipartite'] in [0, 1, '0', '1']:
                return False
    except KeyError:
        return False
    return True
