]> Git — Sourcephile - gargantext.git/blob - clustering-louvain/src/Data/Example.hs
[FEAT] adding clustering louvain.
[gargantext.git] / clustering-louvain / src / Data / Example.hs
1 module Data.Example where
2
3 import Data.List (sort)
4 import Data.Utils
5 import Data.Graph.Inductive
6
7
8 karate :: Gr () Double
9 -- karate = mkGraph' <$> importGraphFromGexf "src/Data/karate.gexf"
10 karate = mkGraph [(1,()),(2,()),(3,()),(4,()),(5,()),(6,()),(7,()),(8,()),(9,()),(10,()),(11,()),(12,()),(13,()),(14,()),(15,()),(16,()),(17,()),(18,()),(19,()),(20,()),(21,()),(22,()),(23,()),(24,()),(25,()),(26,()),(27,()),(28,()),(29,()),(30,()),(31,()),(32,()),(33,()),(34,())] [(1,2,1.0),(1,3,1.0),(1,4,1.0),(1,5,1.0),(1,6,1.0),(1,7,1.0),(1,8,1.0),(1,9,1.0),(1,11,1.0),(1,12,1.0),(1,13,1.0),(1,14,1.0),(1,18,1.0),(1,20,1.0),(1,22,1.0),(1,32,1.0),(2,3,1.0),(2,4,1.0),(2,8,1.0),(2,14,1.0),(2,18,1.0),(2,20,1.0),(2,22,1.0),(2,31,1.0),(3,4,1.0),(3,8,1.0),(3,9,1.0),(3,10,1.0),(3,14,1.0),(3,28,1.0),(3,29,1.0),(3,33,1.0),(4,8,1.0),(4,13,1.0),(4,14,1.0),(5,7,1.0),(5,11,1.0),(6,7,1.0),(6,11,1.0),(6,17,1.0),(7,17,1.0),(9,31,1.0),(9,33,1.0),(9,34,1.0),(10,34,1.0),(14,34,1.0),(15,33,1.0),(15,34,1.0),(16,33,1.0),(16,34,1.0),(19,33,1.0),(19,34,1.0),(20,34,1.0),(21,33,1.0),(21,34,1.0),(23,33,1.0),(23,34,1.0),(24,26,1.0),(24,28,1.0),(24,30,1.0),(24,33,1.0),(24,34,1.0),(25,26,1.0),(25,28,1.0),(25,32,1.0),(26,32,1.0),(27,30,1.0),(27,34,1.0),(28,34,1.0),(29,32,1.0),(29,34,1.0),(30,33,1.0),(30,34,1.0),(31,33,1.0),(31,34,1.0),(32,33,1.0),(32,34,1.0),(33,34,1.0)]
11
12
13 karate2com :: [[Node]]
14 karate2com = sort $ Prelude.map (sort) [[10, 29, 32, 25, 28, 26, 24, 30, 27, 34, 31, 33, 23, 15, 16, 21, 19], [3, 9, 8, 4, 14, 20, 2, 13, 22, 1, 18, 12, 5, 7, 6, 17]]
15
16
17 eU :: [LEdge Double]
18 eU = [
19 (2,1,1)
20 ,(1,2,1)
21
22 ,(1,4,1)
23 ,(4,1,1)
24
25 ,(2,3,1)
26 ,(3,2,1)
27
28 ,(3,4,1)
29 ,(4,3,1)
30
31 ,(4,5,1)
32 ,(5,4,1)
33 ]
34
35 eD :: [LEdge Double]
36 eD = [
37 (2,1,1)
38
39 ,(1,4,1)
40
41 ,(2,3,1)
42
43 ,(3,4,1)
44
45 ,(4,5,1)
46 ]
47
48 gU :: Gr () Double
49 gU = mkGraph' eU
50
51 -- > prettyPrint gU
52 -- 1:()->[(1,2),(1,4)]
53 -- 2:()->[(1,1),(1,3)]
54 -- 3:()->[(1,2),(1,4)]
55 -- 4:()->[(1,1),(1,3),(1,5)]
56 -- 5:()->[(1,4)]
57
58 -- Visual representation:
59 --
60 -- 2
61 -- / \
62 -- 1 3
63 -- \ /
64 -- 4
65 -- |
66 -- 5
67 --
68 --
69
70 gD :: Gr () Double
71 gD = mkGraph' eD
72
73 eD' :: [LEdge Double]
74 eD' = [
75 (2,1,1)
76
77 ,(1,4,1)
78
79 ,(2,3,1)
80
81 ,(3,4,1)
82
83 ,(4,5,1)
84 ,(5,6,1)
85 ,(5,7,1)
86 ,(6,7,1)
87 ]
88 gD' :: Gr () Double
89 gD' = mkGraph' eD'