def keyphrases_graph(keyphrases, texts, referral_confidence=0.6, relevance_threshold=0.25,
                     support_threshold=1, similarity_measure=None, synonimizer=None,
                     language=consts.Language.ENGLISH):
    similarity_measure = similarity_measure or relevance.ASTRelevanceMeasure()
    table = keyphrases_table(keyphrases, texts, similarity_measure, synonimizer, language)
    keyphrase_texts = {keyphrase: set([text for text in texts
                                       if table[keyphrase][text] >= relevance_threshold])
                       for keyphrase in keyphrases}
    graph = {
        "nodes": [
            {
                "id": i,
                "label": keyphrase,
                "support": len(keyphrase_texts[keyphrase])
            } for i, keyphrase in enumerate(keyphrases)
        ],
        "edges": [],
        "referral_confidence": referral_confidence,
        "relevance_threshold": relevance_threshold,
        "support_threshold": support_threshold
    }
    graph["nodes"] = [n for n in graph["nodes"]
                      if len(keyphrase_texts[n["label"]]) >= support_threshold]
    for i1, i2 in itertools.permutations(range(len(graph["nodes"])), 2):
        node1 = graph["nodes"][i1]
        node2 = graph["nodes"][i2]
        confidence = (float(len(keyphrase_texts[node1["label"]] &
                                keyphrase_texts[node2["label"]])) /
                      max(len(keyphrase_texts[node1["label"]]), 1))
        if confidence >= referral_confidence:
            graph["edges"].append({
                "source": node1["id"],
                "target": node2["id"],
                "confidence": confidence
            })
    return graph