Commit ff1c07d8 authored by Yoann Dufresne's avatar Yoann Dufresne
Browse files

add a little bit of documentation to understand the d_graph detection code

parent 4c766588
......@@ -46,12 +46,25 @@ def get_communities(G):
# Extract communites from all the possible d-graphes in the neighborood.
""" This function take two cliques in the graph G and try to find if they are 2 halfes of a d-graph.
1 - The algorithm compute overlapp between nodes from first clique to the second and from the
second to the first.
2 - Filter the clique pairs that have less than n*(n-1)/2 traversing edges (necessary critera
to be considered as d-graph).
3 - Find the node order in the half d-graphs by sorting nodes by traversing order.
4 - return a paair of half d-graph ordered from the central node (not present in G).
@param cliq1 (resp clq2) the clique that is candidate to be composed of half of the d-graph nodes.
@param G the graph of the neighbors of the central node (not present).
@return A pair of lists that are the 2 halves of the d-graph ordered from the center.
def compute_d_graph(clq1, clq2, G):
# Compute the arities between the cliques
arities1 = {name:0 for name in clq1}
arities2 = {name:0 for name in clq2}
sum_edges = 0
min_clq_size = min(len(clq1), len(clq2))
# Compute link arities
for node1 in clq1:
neighbors = list(G.neighbors(node1))
......@@ -64,7 +77,7 @@ def compute_d_graph(clq1, clq2, G):
sum_edges += 1
# Reject if not enought edges
if sum_edges < len(clq1) * (len(clq1)-1) / 2:
if sum_edges < min_clq_size * (min_clq_size-1) / 2:
return None
print(clq1, clq2)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment