Commit a77a1cb9 authored by delanoe's avatar delanoe

[FEAT] some tests to filter links distributional distance.

parent 3c74cc79
...@@ -2,10 +2,11 @@ from admin.utils import PrintException ...@@ -2,10 +2,11 @@ from admin.utils import PrintException
from gargantext_web.db import * from gargantext_web.db import *
from collections import defaultdict from collections import defaultdict
from operator import itemgetter
from django.db import connection, transaction from django.db import connection, transaction
import math import math
from math import log from math import log,sqrt
import scipy import scipy
...@@ -149,6 +150,10 @@ def do_distance(cooc_id, field1=None, field2=None, isMonopartite=True, distance= ...@@ -149,6 +150,10 @@ def do_distance(cooc_id, field1=None, field2=None, isMonopartite=True, distance=
if i != j and r[i][j] > minmax and r[i][j] > r[j][i] if i != j and r[i][j] > minmax and r[i][j] > r[j][i]
] ]
) )
# degree_max = max([(n, d) for n,d in G.degree().items()], key=itemgetter(1))[1]
# nodes_to_remove = [n for (n,d) in G.degree().items() if d <= round(degree_max/2)]
# G.remove_nodes_from(nodes_to_remove)
# Removing too connected nodes (find automatic way to do it) # Removing too connected nodes (find automatic way to do it)
#edges_to_remove = [ e for e in G.edges_iter() if #edges_to_remove = [ e for e in G.edges_iter() if
...@@ -156,6 +161,9 @@ def do_distance(cooc_id, field1=None, field2=None, isMonopartite=True, distance= ...@@ -156,6 +161,9 @@ def do_distance(cooc_id, field1=None, field2=None, isMonopartite=True, distance=
# nodes_to_remove = [n for n in degree if degree[n] <= 1] # nodes_to_remove = [n for n in degree if degree[n] <= 1]
# G.remove_nodes_from(nodes_to_remove) # G.remove_nodes_from(nodes_to_remove)
def getWeight(item): def getWeight(item):
return item[1] return item[1]
# #
......
Markdown is supported
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