1 {-| Module : Gargantext.Viz.Graph.IGraph
2 Description : IGraph main functions used in Garg
3 Copyright : (c) CNRS, 2017-Present
4 License : AGPL + CECILL v3
5 Maintainer : team@gargantext.org
6 Stability : experimental
9 Main IGraph funs/types to ease portability with FGL.
13 {-# LANGUAGE NoImplicitPrelude #-}
14 {-# LANGUAGE DataKinds #-}
16 module Gargantext.Viz.Graph.IGraph where
18 import Data.Serialize (Serialize)
19 import Data.Singletons (SingI)
20 import Gargantext.Prelude
21 import IGraph hiding (mkGraph, neighbors, edges, nodes, Node, Graph)
22 import IGraph.Algorithms.Clique as IAC
23 import qualified IGraph as IG
24 import qualified Data.List as List
26 ------------------------------------------------------------------
28 type Graph_Undirected = IG.Graph 'U () ()
29 type Graph_Directed = IG.Graph 'D () ()
34 ------------------------------------------------------------------
37 mkGraph :: (SingI d, Ord v,
38 Serialize v, Serialize e) =>
39 [v] -> [LEdge e] -> IG.Graph d v e
42 neighbors :: IG.Graph d v e -> IG.Node -> [Node]
43 neighbors = IG.neighbors
45 edges :: IG.Graph d v e -> [Edge]
48 nodes :: IG.Graph d v e -> [Node]
50 ------------------------------------------------------------------
53 maximalCliques :: IG.Graph d v e -> [[Int]]
54 maximalCliques g = IAC.maximalCliques g (min',max')
59 ------------------------------------------------------------------
60 -- | Main sugared functions
61 mkGraphUfromEdges :: [(Int, Int)] -> Graph_Undirected
62 mkGraphUfromEdges es = mkGraph (List.replicate n ()) $ zip es $ repeat ()
65 n = List.length (List.nub $ a <> b)
67 mkGraphDfromEdges :: [(Int, Int)] -> Graph_Directed
68 mkGraphDfromEdges = undefined