Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
199
Issues
199
List
Board
Labels
Milestones
Merge Requests
12
Merge Requests
12
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
haskell-gargantext
Commits
3da7a409
Commit
3da7a409
authored
Oct 21, 2024
by
Karen Konou
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Graph] Generate legend when computing graph
parent
3030272d
Pipeline
#6877
failed with stages
in 48 minutes and 59 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
6 deletions
+22
-6
API.hs
src/Gargantext/Core/Viz/Graph/API.hs
+13
-5
Tools.hs
src/Gargantext/Core/Viz/Graph/Tools.hs
+9
-1
No files found.
src/Gargantext/Core/Viz/Graph/API.hs
View file @
3da7a409
...
...
@@ -75,8 +75,9 @@ getGraph nId = do
let
defaultBridgenessMethod
=
BridgenessMethod_Basic
graph'
<-
computeGraph
cId
defaultPartitionMethod
defaultBridgenessMethod
(
withMetric
defaultMetric
)
defaultEdgesStrength
(
NgramsTerms
,
NgramsTerms
)
repo
mt
<-
defaultGraphMetadata
cId
listId
"Title"
repo
defaultMetric
defaultEdgesStrength
let
mt'
=
set
gm_legend
(
generateLegend
graph'
)
mt
let
graph''
=
set
graph_metadata
(
Just
mt
)
graph'
graph''
=
set
graph_metadata
(
Just
mt
'
)
graph'
hg
=
HyperdataGraphAPI
graph''
camera
-- _ <- updateHyperdata nId hg
_
<-
updateHyperdata
nId
(
HyperdataGraph
(
Just
graph''
)
camera
)
...
...
@@ -126,20 +127,27 @@ recomputeGraph nId partitionMethod bridgeMethod maybeSimilarity maybeStrength nt
let
computeG
mt
=
do
!
g
<-
computeGraph
cId
partitionMethod
bridgeMethod
similarity
strength
(
nt1
,
nt2
)
repo
let
g'
=
set
graph_metadata
mt
g
let
mt'
=
set
gm_legend
(
generateLegend
g
)
mt
let
g'
=
set
graph_metadata
(
Just
mt'
)
g
_nentries
<-
updateHyperdata
nId
(
HyperdataGraph
(
Just
g'
)
camera
)
pure
g'
case
graph
of
Nothing
->
do
mt
<-
defaultGraphMetadata
cId
listId
"Title"
repo
(
fromMaybe
Order1
maybeSimilarity
)
strength
g
<-
computeG
$
Just
mt
g
<-
computeG
mt
pure
$
trace
(
"[G.V.G.API.recomputeGraph] Graph empty, computed"
::
Text
)
g
Just
graph'
->
if
(
listVersion
==
Just
v
)
&&
(
not
force'
)
then
pure
graph'
else
do
g
<-
computeG
graphMetadata
pure
$
trace
(
"[G.V.G.API] Graph exists, recomputing"
::
Text
)
g
case
graphMetadata
of
Nothing
->
do
mt
<-
defaultGraphMetadata
cId
listId
"Title"
repo
(
fromMaybe
Order1
maybeSimilarity
)
strength
g
<-
computeG
mt
pure
$
trace
(
"[G.V.G.API] Graph exists, no metadata, recomputing"
::
Text
)
g
Just
mt
->
do
g
<-
computeG
mt
pure
$
trace
(
"[G.V.G.API] Graph exists, recomputing"
::
Text
)
g
-- TODO remove repo
...
...
src/Gargantext/Core/Viz/Graph/Tools.hs
View file @
3da7a409
...
...
@@ -34,7 +34,7 @@ import Gargantext.Core.Viz.Graph.Bridgeness (bridgeness, Bridgeness(..), Partiti
import
Gargantext.Core.Viz.Graph.Index
(
createIndices
,
toIndex
,
map2mat
,
mat2map
,
Index
,
MatrixShape
(
..
))
import
Gargantext.Core.Viz.Graph.Tools.IGraph
(
mkGraphUfromEdges
,
spinglass
,
spinglass'
)
import
Gargantext.Core.Viz.Graph.Tools.Infomap
(
infomap
)
import
Gargantext.Core.Viz.Graph.Types
(
Attributes
(
..
),
Edge
(
..
),
Graph
(
..
),
MultiPartite
(
..
),
Node
(
..
),
Partite
(
..
),
Strength
(
..
))
import
Gargantext.Core.Viz.Graph.Types
(
Attributes
(
..
),
Edge
(
..
),
Graph
(
..
),
MultiPartite
(
..
),
Node
(
..
),
Partite
(
..
),
Strength
(
..
)
,
LegendField
(
..
)
)
import
Gargantext.Core.Viz.Graph.Utils
(
edgesFilter
,
nodesFilter
)
import
Gargantext.Prelude
import
Graph.BAC.ProxemyOptim
qualified
as
BAC
...
...
@@ -377,3 +377,11 @@ filterByNeighbours threshold distanceMap = filteredMap
$
Map
.
filterWithKey
(
\
(
from'
,
_
)
_
->
idx
==
from'
)
distanceMap
in
List
.
take
(
round
threshold
)
selected
)
indexes
generateLegend
::
Graph
->
[
LegendField
]
generateLegend
(
Graph
{
_graph_nodes
=
nodes
})
=
List
.
sortBy
(
\
(
LegendField
{
_lf_id
=
a
})
(
LegendField
{
_lf_id
=
b
})
->
compare
a
b
)
$
foldl'
f
[]
nodes
where
f
::
[
LegendField
]
->
Node
->
[
LegendField
]
f
acc
(
Node
{
node_attributes
=
Attributes
{
clust_default
=
i
}})
=
case
List
.
find
(
\
(
LegendField
{
_lf_id
})
->
_lf_id
==
i
)
acc
of
Just
_
->
acc
Nothing
->
acc
++
[
LegendField
{
_lf_id
=
i
,
_lf_label
=
"Cluster"
<>
show
i
,
_lf_color
=
"#FFF"
}]
Przemyslaw Kaminski
@cgenie
mentioned in commit
83c8708f
·
Nov 07, 2024
mentioned in commit
83c8708f
mentioned in commit 83c8708f08e563243a0ff361e51a46c7d7822bb7
Toggle commit list
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