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.
12 * Gábor Csárdi, Tamás Nepusz: The igraph software package for complex network research. InterJournal Complex Systems, 1695, 2006.
17 module Gargantext.Viz.Graph.IGraph where
19 import Data.Serialize (Serialize)
20 import Data.Singletons (SingI)
21 import Gargantext.Prelude
22 import IGraph hiding (mkGraph, neighbors, edges, nodes, Node, Graph)
23 import IGraph.Algorithms.Clique as IAC
24 import qualified IGraph as IG
25 import qualified Data.List as List
27 ------------------------------------------------------------------
29 type Graph_Undirected = IG.Graph 'U () ()
30 type Graph_Directed = IG.Graph 'D () ()
35 ------------------------------------------------------------------
38 mkGraph :: (SingI d, Ord v,
39 Serialize v, Serialize e) =>
40 [v] -> [LEdge e] -> IG.Graph d v e
43 neighbors :: IG.Graph d v e -> IG.Node -> [Node]
44 neighbors = IG.neighbors
46 edges :: IG.Graph d v e -> [Edge]
49 nodes :: IG.Graph d v e -> [Node]
51 ------------------------------------------------------------------
54 maximalCliques :: IG.Graph d v e -> [[Int]]
55 maximalCliques g = IAC.maximalCliques g (min',max')
60 ------------------------------------------------------------------
61 -- | Main sugared functions
62 mkGraphUfromEdges :: [(Int, Int)] -> Graph_Undirected
63 mkGraphUfromEdges es = mkGraph (List.replicate n ()) $ zip es $ repeat ()
66 n = List.length (List.nub $ a <> b)
68 mkGraphDfromEdges :: [(Int, Int)] -> Graph_Directed
69 mkGraphDfromEdges = undefined