def hierarchy_cycles(rdf, fix=False):
top_concepts = sorted(rdf.subject_objects(SKOS.hasTopConcept))<EOL>status = {}<EOL>for cs, root in top_concepts:<EOL><INDENT>_hierarchy_cycles_visit(<EOL>rdf, root, None, fix, status=status)<EOL><DEDENT>recheck_top_concepts = False<EOL>for conc in sorted(rdf.subjects(RDF.type, SKOS.Concept)):<EOL><INDENT>if conc not in status:<EOL><INDENT>recheck_top_concepts = True<EOL>_hierarchy_cycles_visit(<EOL>rdf, conc, None, fix, status=status)<EOL><DEDENT><DEDENT>return recheck_top_concepts<EOL>
Check if the graph contains skos:broader cycles and optionally break these.

    :param Graph rdf: An rdflib.graph.Graph object.
    :param bool fix: Fix the problem by removing any skos:broader that overlaps
        with skos:broaderTransitive.