Order 1 advanced distance
Summary
The goal is to implement an advanced Order 1 distance such that interclusters links are filtered according to their absolute weight.
Where
The function to add is in Gargantext > Core > Viz > Graph > Bridgeness.hs It is a variant of filterComs :
---- This function implemented in Order 1 graph distance, to be renamed something like 'O1 simple' takes the same number of links for each clusters pairs. ---------
filterComs :: (Ord n1, Eq n2)
=> Int
-> Map (n2, n2) [(a3, n1)]
-> Map (n2, n2) [(a3, n1)]
filterComs b m = Map.filter (\n -> length n > 0) $ mapWithKey filter' m
where
filter' (c1,c2) a
| c1 == c2 = a
-- TODO use n here
| otherwise = take (b * 2*n) $ List.sortOn (Down . snd) a
where
n :: Int
n = round $ 100 * a' / t
a'= fromIntegral $ length a
t :: Double
t = fromIntegral $ length $ List.concat $ elems m
The alternative function, filterComs', let's call it for now 'Order1 Advanced', filter all inter-cluster links below a threshold. This threshold should ideally be a parameter at generation:
-- Weak links are often due to noise in the data and decrease the readability of the graph.
-- This function prunes the links between the clusters when their weight is under a given 'threshold'.
filterComs' :: (Ord a1, Fractional a1, Eq a2) =>
Int -> Map (a2, a2) [(a3, a1)] -> Map (a2, a2) [(a3, a1)]
filterComs' _b m = Map.filter (\n -> length n > 0) $ mapWithKey filter' m
where
threshold=0.03 -- this threshold will be moved to user parameters
filter' (c1,c2) xs
| c1 == c2 = xs
| otherwise = List.filter (\(_nn,v) -> v >= threshold) xs
The goal of this issue is to create a new choice in the Graph distance drop down:
such that users can choose either simple O1 maps that highlights clusters or advanced O1 maps that enable to explore the relations between clusters.