Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
clustering-louvain
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
clustering-louvain
Commits
adbc3f53
Commit
adbc3f53
authored
Mar 28, 2020
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'flouvain' of
ssh://gitlab.iscpif.fr:20022/gargantext/clustering-louvain
into flouvain
parents
bc60e0a6
94be2a54
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
11 deletions
+27
-11
ILouvain.hs
src/Data/Graph/Clustering/ILouvain.hs
+27
-11
No files found.
src/Data/Graph/Clustering/ILouvain.hs
View file @
adbc3f53
...
@@ -14,25 +14,37 @@ ILouvain: really inductive Graph
...
@@ -14,25 +14,37 @@ ILouvain: really inductive Graph
module
Data.Graph.Clustering.ILouvain
module
Data.Graph.Clustering.ILouvain
where
where
import
Data.Set
(
fromList
)
import
Data.Maybe
(
catMaybes
)
import
Data.Maybe
(
catMaybes
)
import
Data.List
(
zip
,
cycle
)
import
Data.List
(
zip
,
cycle
)
import
Protolude
hiding
(
empty
,
(
&
))
import
Protolude
hiding
(
empty
,
(
&
))
import
Data.Graph.Inductive
import
Data.Graph.Inductive
import
qualified
Data.Graph.Clustering.HLouvain
as
H
------------------------------------------------------------------------
------------------------------------------------------------------------
-- HyperGraph Definition
-- HyperGraph Definition
type
HyperGraph
a
b
=
Gr
(
Gr
()
a
)
b
type
HyperGraph
a
b
=
Gr
(
Gr
()
a
)
b
type
HyperContext
a
b
=
Context
(
Gr
()
a
)
b
type
HyperContext
a
b
=
Context
(
Gr
()
a
)
b
-- TODO Later (hypothesis still)
-- type StreamGraph a b = Gr a (Gr () b)
toInfra
::
Gr
(
Gr
()
a
)
b
->
Gr
()
a
toInfra
=
undefined
toSupra
::
Gr
()
a
->
Gr
(
Gr
()
a
)
b
hnodes
::
HyperGraph
a
b
->
Node
->
[
Node
]
toSupra
=
undefined
hnodes
g
n
=
case
match
n
g
of
(
Nothing
,
_
)
->
[]
(
Just
(
p
,
n
,
l
,
s
),
_
)
->
n
:
nodes
l
hedges
::
HyperGraph
a
b
->
Node
->
[
Edge
]
hedges
=
undefined
hneighbors
::
HyperGraph
a
b
->
Node
->
[
Node
]
hneighbors
=
undefined
------------------------------------------------------------------------
modularity
::
HyperGraph
a
b
->
[
Node
]
->
Double
modularity
g
ns
=
H
.
modularity
g
(
fromList
ns
)
-- TODO Later (hypothesis still)
-- type StreamGraph a b = Gr a (Gr () b)
------------------------------------------------------------------------
------------------------------------------------------------------------
-- Spoon Graph
-- Spoon Graph
-- 1
-- 1
...
@@ -78,14 +90,16 @@ mv g [ ] [ ] = g
...
@@ -78,14 +90,16 @@ mv g [ ] [ ] = g
mv
g
[
_
]
[ ]
=
g
mv
g
[
_
]
[ ]
=
g
mv
g
[ ]
[
_
]
=
g
mv
g
[ ]
[
_
]
=
g
mv
g
[
a
]
[
b
]
=
mv'
g
a
b
mv
g
[
a
]
[
b
]
=
case
a
==
b
of
True
->
panic
"mv, impossible: moved node is same as destination"
False
->
mv'
g
a
b
mv
g
[
a
,
b
]
[ ]
=
case
match
a
g
of
mv
g
[
a
,
b
]
[ ]
=
case
match
a
g
of
(
Nothing
,
_
)
->
panic
"mv: fst Node of Path does not exist"
(
Nothing
,
_
)
->
panic
"mv: fst Node of Path does not exist"
(
Just
(
p
,
n
,
l
,
s
),
g1
)
->
case
match
b
l
of
(
Just
(
p
,
n
,
l
,
s
),
g1
)
->
case
match
b
l
of
(
Just
(
p'
,
n'
,
l'
,
s'
),
g2
)
->
(
p'
,
n'
,
g2
,
s'
)
&
((
p
,
n
,
delNode
b
l
,
s
)
&
g1
)
(
Nothing
,
_
)
->
panic
"mv: snd Node of Path does not exist"
(
Nothing
,
_
)
->
panic
"mv: snd Node of Path does not exist"
(
Just
(
p'
,
n'
,
l'
,
s'
),
g2
)
->
(
p'
,
n'
,
g2
,
s'
)
-- & (p , n , delNode b l, s )
&
g1
mv
g
(
x
:
xs
)
(
y
:
ys
)
=
panic
"mv: path too long"
mv
g
(
x
:
xs
)
(
y
:
ys
)
=
panic
"mv: path too long"
...
@@ -116,7 +130,9 @@ merge :: (Graph gr, DynGraph gr)
...
@@ -116,7 +130,9 @@ merge :: (Graph gr, DynGraph gr)
=>
gr
a
b
->
gr
a
b
->
gr
a
b
=>
gr
a
b
->
gr
a
b
->
gr
a
b
merge
=
ufold
(
&
)
merge
=
ufold
(
&
)
------------------------------------------------------------------------
test_mv
::
Ord
a
=>
HyperGraph
a
a
->
Node
->
Node
->
Bool
test_mv
g
a
b
=
(
mv
(
mv
g
[
a
]
[
b
])
[
b
,
a
]
[]
)
==
g
------------------------------------------------------------------------
------------------------------------------------------------------------
-- | Recursive Node of Graph
-- | Recursive Node of Graph
{-
{-
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment