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 qualified IGraph as IG
23 import qualified Data.List as List
25 ------------------------------------------------------------------
27 type Graph_Undirected = IG.Graph 'U () ()
28 type Graph_Directed = IG.Graph 'D () ()
33 ------------------------------------------------------------------
36 mkGraph :: (SingI d, Ord v,
37 Serialize v, Serialize e) =>
38 [v] -> [LEdge e] -> IG.Graph d v e
41 neighbors :: IG.Graph d v e -> IG.Node -> [Node]
42 neighbors = IG.neighbors
44 edges :: IG.Graph d v e -> [Edge]
47 nodes :: IG.Graph d v e -> [Node]
50 ------------------------------------------------------------------
51 -- | Main sugared functions
53 mkGraphUfromEdges :: [(Int, Int)] -> Graph_Undirected
54 mkGraphUfromEdges es = mkGraph (List.replicate n ()) $ zip es $ repeat ()
57 n = List.length (List.nub $ a <> b)
59 mkGraphDfromEdges :: [(Int, Int)] -> Graph_Directed
60 mkGraphDfromEdges = undefined