Commit 99f5ac3d authored by Alexandre Delanoë's avatar Alexandre Delanoë

[WIP] another way to optimize

parent d721d97d
...@@ -52,19 +52,21 @@ type Confluence = Map (NodeId, NodeId) Double ...@@ -52,19 +52,21 @@ type Confluence = Map (NodeId, NodeId) Double
bridgeness3 :: Confluence bridgeness3 :: Confluence
-> Map (NodeId, NodeId) Double -> Map (NodeId, NodeId) Double
-> Map (NodeId, NodeId) Double -> Map (NodeId, NodeId) Double
bridgeness3 c m = Map.fromList bridgeness3 c m = trace ("bridgeness c' size: " <> (show $ List.length c'))
$ map fst $ Map.fromList
$ List.take n $ map (\(ks, (v1,_v2)) -> (ks,v1))
$ List.sortOn (Down . snd) $ List.take n
$ catMaybes -- $ List.sortOn (Down . (snd . snd))
$ map (\(ks,v) -> (,) <$> Just (ks,v) <*> look ks c') $ Map.toList c'
$ Map.toList m
where where
!c' = map2intMap c -- !c' = map2intMap c
!c' = Map.intersectionWithKey (\_k v1 v2 -> (v1, v2)) m c
!m' = Map.toList m !m' = Map.toList m
n :: Int n :: Int
!n = trace ("bridgeness m size: " <> (show $ List.length m')) $ round $ (fromIntegral $ List.length m') / (10 :: Double) !n = trace ("bridgeness m size: " <> (show $ List.length m'))
$ round
$ (fromIntegral $ List.length m') / (10 :: Double)
map2intMap :: Map (Int, Int) a -> IntMap (IntMap a) map2intMap :: Map (Int, Int) a -> IntMap (IntMap a)
......
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