Commit e609dd8b authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FIX] Spinglass not connected components

parent 407af151
...@@ -63,18 +63,17 @@ spinglass :: Seed -> Map (Int, Int) Double -> IO [ClusterNode] ...@@ -63,18 +63,17 @@ spinglass :: Seed -> Map (Int, Int) Double -> IO [ClusterNode]
spinglass s g = toClusterNode spinglass s g = toClusterNode
<$> map catMaybes <$> map catMaybes
<$> map (map (\n -> Map.lookup n fromI)) <$> map (map (\n -> Map.lookup n fromI))
<$> partitions_spinglass' s g''' <$> List.concat
<$> mapM (partitions_spinglass' s) g'
where where
g' = toIndex toI g -- Not connected components of the graph make crash spinglass
g'' = mkGraphUfromEdges (Map.keys g') g' = IG.decompose $ mkGraphUfromEdges
g''' = case IG.isConnected g'' of $ Map.keys
True -> g'' $ toIndex toI g
False -> case head (IG.decompose g'') of
Nothing -> panic "[G.C.V.G.T.Igraph: not connected graph]"
Just g'''' -> g''''
(toI, fromI) = createIndices g (toI, fromI) = createIndices g
-- | Tools to analyze graphs -- | Tools to analyze graphs
partitions_spinglass' :: (Serialize v, Serialize e) partitions_spinglass' :: (Serialize v, Serialize e)
=> Seed -> IG.Graph 'U v e -> IO [[Int]] => Seed -> IG.Graph 'U v e -> IO [[Int]]
......
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