Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gargantext-graph
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
gargantext-graph
Commits
7664c2ef
Commit
7664c2ef
authored
Jul 01, 2021
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FEAT] last needed function to start tests
parent
786b4880
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
15 deletions
+57
-15
ProxemyOptim.hs
src/Graph/BAC/ProxemyOptim.hs
+57
-15
No files found.
src/Graph/BAC/ProxemyOptim.hs
View file @
7664c2ef
...
...
@@ -28,29 +28,29 @@ Gaume.
module
Graph.BAC.ProxemyOptim
where
import
Prelude
(
String
,
readLn
)
--import Debug.SimpleReflect
import
Data.IntMap
(
IntMap
)
import
Data.Maybe
(
isJust
)
import
Data.Proxy
(
Proxy
(
Proxy
))
import
GHC.TypeLits
(
KnownNat
,
Nat
,
SomeNat
(
SomeNat
),
type
(
+
),
natVal
,
sameNat
,
someNatVal
)
import
Data.Reflection
--import Debug.SimpleReflect
import
Data.Map
(
Map
)
import
Eigen.Internal
(
CTriplet
(
..
),
Elem
(
..
),
toC
,
fromC
,
C
(
..
),
natToInt
,
Row
(
..
),
Col
(
..
))
import
Eigen.Matrix
(
sum
,
unsafeCoeff
)
import
Eigen.SparseMatrix
(
SparseMatrix
,
SparseMatrixXd
,
(
!
),
toMatrix
,
_unsafeCoeff
)
import
GHC.TypeLits
(
KnownNat
,
Nat
,
SomeNat
(
SomeNat
),
type
(
+
),
natVal
,
sameNat
,
someNatVal
)
import
Graph.FGL
import
Prelude
(
String
,
readLn
)
import
Protolude
hiding
(
sum
,
natVal
)
import
qualified
Eigen.Matrix
as
DenseMatrix
import
Eigen.SparseMatrix
(
SparseMatrix
,
SparseMatrixXd
,
(
!
),
toMatrix
,
_unsafeCoeff
)
import
Eigen.Internal
(
CTriplet
(
..
),
Elem
(
..
),
toC
,
fromC
,
C
(
..
),
natToInt
,
Row
(
..
),
Col
(
..
))
import
Eigen.Matrix
(
sum
,
unsafeCoeff
)
import
qualified
Eigen.Matrix
as
DMatrix
import
qualified
Data.Graph.Inductive
as
DGI
import
qualified
Data.Graph.Inductive.PatriciaTree
as
DGIP
import
qualified
Data.List
as
List
import
qualified
Data.Map
as
Map
import
qualified
Data.Vector.Storable
as
VS
import
qualified
Data.IntMap
as
Dict
import
qualified
Data.Vector
as
V
import
qualified
Data.Vector.Storable
as
VS
import
qualified
Eigen.Matrix
as
DMatrix
import
qualified
Eigen.SparseMatrix
as
SMatrix
import
qualified
Prelude
as
Prelude
import
qualified
Prelude
as
Prelude
import
qualified
Data.Set
as
Set
-- | Main Types
type
Length
=
Int
...
...
@@ -112,8 +112,10 @@ data SimilarityMatrix n = SimConf (ConfluenceMatrix n)
|
SimMod
(
ModularityMatrix
n
)
data
Similarity
=
Conf
|
Mod
data
Clustering
a
=
Clustering
{
partitions
::
Set
(
Set
a
)
,
score
::
Double
type
Dict
=
IntMap
data
Clustering
a
=
Clustering
{
parts
::
Dict
(
Set
a
)
,
index
::
Dict
Int
,
score
::
Double
}
-- TODO
...
...
@@ -256,12 +258,52 @@ sort_edges n = List.concat
---------------------------------------------------------------
updateWith
::
Clustering
Node
->
(
Int
->
Int
->
Double
)
->
(
Int
,
Int
)
->
(
Int
,
Int
)
->
Clustering
Node
updateWith
c
@
(
Clustering
parts
idx
_
)
f
(
modX
,
x
)
(
modY
,
y
)
=
Clustering
parts'
idx'
score'
where
parts'
=
Dict
.
alter
(
del
y
)
modY
$
Dict
.
alter
(
add
y
)
modX
parts
add
y
Nothing
=
Just
(
Set
.
singleton
y
)
add
y
(
Just
y'
)
=
Just
(
Set
.
insert
y
y'
)
del
y
Nothing
=
Nothing
del
y
(
Just
y'
)
=
Just
(
Set
.
delete
y
y'
)
idx'
=
Dict
.
alter
(
alter
modY
)
y
idx
alter
my
_
=
Just
my
px
=
fromMaybe
Set
.
empty
$
Dict
.
lookup
x
parts'
py
=
fromMaybe
Set
.
empty
$
Dict
.
lookup
y
parts'
score'
=
Prelude
.
sum
[
f
x''
y''
|
x''
<-
Set
.
toList
px
,
y''
<-
Set
.
toList
py
]
updateClustering
::
Clustering
Node
->
(
Int
->
Int
->
Double
)
->
Int
->
Int
->
Clustering
Node
updateClustering
c
@
(
Clustering
parts
idx
currentScore
)
f
x
y
=
let
modX
=
fromMaybe
0
$
Dict
.
lookup
x
idx
modY
=
fromMaybe
0
$
Dict
.
lookup
y
idx
in
case
x
==
y
||
modX
==
modY
of
True
->
c
-- do case x' or y' are Nothing
False
->
let
c'
=
updateWith
c
f
(
x
,
modX
)
(
y
,
modY
)
in
case
score
c'
>
currentScore
of
True
->
c'
False
->
c
make_clust_part
::
KnownNat
n
=>
SortedEdges
->
SimilarityMatrix
n
->
Clustering
Node
make_clust_part
=
undefined
make_clust_part
se
sm
=
foldl'
(
\
c
(
e1
,
e2
,
_
)
->
updateClustering
c
(
\
x
y
->
unsafeCoeff
e1
e2
sm'
)
e1
e2
)
(
Clustering
Dict
.
empty
Dict
.
empty
0
)
se
where
sm'
=
case
sm
of
SimConf
cm
->
cm
SimMod
mm
->
mm
---------------------------------------------------------------
make_clust_over
::
KnownNat
n
=>
SimilarityMatrix
n
->
StrictClustering
a
...
...
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