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
0
Issues
0
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
Julien Moutinho
haskell-gargantext
Commits
808c69a1
Commit
808c69a1
authored
Jun 19, 2018
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[GRAPH] Old graph format of gargantext utils to convert.
parent
a10e3b30
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
81 additions
and
23 deletions
+81
-23
TextFlow.hs
src/Gargantext/TextFlow.hs
+9
-9
Graph.hs
src/Gargantext/Viz/Graph.hs
+72
-14
No files found.
src/Gargantext/TextFlow.hs
View file @
808c69a1
...
...
@@ -130,18 +130,18 @@ data2graph :: [(Label, Int)] -> Map (Int, Int) Int
data2graph
labels
coocs
distance
partitions
=
Graph
nodes
edges
where
community_id_by_node_id
=
M
.
fromList
[
(
n
,
c
)
|
LouvainNode
n
c
<-
partitions
]
nodes
=
[
Node
{
n_size
=
maybe
0
identity
(
M
.
lookup
(
n
,
n
)
coocs
)
,
n_type
=
Terms
-- or Unknown
,
n_id
=
cs
(
show
n
)
,
n_label
=
T
.
unwords
l
,
n_attributes
=
nodes
=
[
Node
{
n
ode
_size
=
maybe
0
identity
(
M
.
lookup
(
n
,
n
)
coocs
)
,
n
ode
_type
=
Terms
-- or Unknown
,
n
ode
_id
=
cs
(
show
n
)
,
n
ode
_label
=
T
.
unwords
l
,
n
ode
_attributes
=
Attributes
{
clust_default
=
maybe
0
identity
(
M
.
lookup
n
community_id_by_node_id
)
}
}
|
(
l
,
n
)
<-
labels
]
edges
=
[
Edge
{
e
_source
=
s
,
e
_target
=
t
,
e_weight
=
w
,
e
_id
=
i
}
edges
=
[
Edge
{
e
dge_source
=
cs
(
show
s
)
,
e
dge_target
=
cs
(
show
t
)
,
e
dge
_weight
=
w
,
e
dge_id
=
cs
(
show
i
)
}
|
(
i
,
((
s
,
t
),
w
))
<-
zip
[
0
..
]
(
M
.
toList
distance
)
]
-----------------------------------------------------------
...
...
src/Gargantext/Viz/Graph.hs
View file @
808c69a1
...
...
@@ -16,9 +16,17 @@ Portability : POSIX
module
Gargantext.Viz.Graph
where
import
GHC.IO
(
FilePath
)
import
GHC.Generics
(
Generic
)
import
Data.Aeson.TH
(
deriveJSON
)
import
qualified
Data.Aeson
as
DA
import
Data.ByteString.Lazy
as
DBL
(
readFile
,
writeFile
)
import
Data.Text
(
Text
)
import
qualified
Text.Read
as
T
import
qualified
Data.Text
as
T
import
Data.Map
(
Map
)
import
Gargantext.Prelude
...
...
@@ -36,28 +44,78 @@ data Attributes = Attributes { clust_default :: Int }
deriving
(
Show
,
Generic
)
$
(
deriveJSON
(
unPrefix
""
)
''
A
ttributes
)
data
Node
=
Node
{
n
_size
::
Int
,
n
_type
::
TypeNode
,
n
_id
::
Text
,
n_label
::
Text
,
n_attributes
::
Attributes
data
Node
=
Node
{
n
ode_size
::
Int
,
n
ode_type
::
TypeNode
,
n
ode_id
::
Text
,
n
ode
_label
::
Text
,
n
ode
_attributes
::
Attributes
}
deriving
(
Show
,
Generic
)
$
(
deriveJSON
(
unPrefix
"n_"
)
''
N
ode
)
$
(
deriveJSON
(
unPrefix
"n
ode
_"
)
''
N
ode
)
data
Edge
=
Edge
{
e
_source
::
In
t
,
e
_target
::
In
t
,
e_weight
::
Double
,
e
_id
::
In
t
data
Edge
=
Edge
{
e
dge_source
::
Tex
t
,
e
dge_target
::
Tex
t
,
e
dge
_weight
::
Double
,
e
dge_id
::
Tex
t
}
deriving
(
Show
,
Generic
)
$
(
deriveJSON
(
unPrefix
"e_"
)
''
E
dge
)
$
(
deriveJSON
(
unPrefix
"e
dge
_"
)
''
E
dge
)
data
Graph
=
Graph
{
g_nodes
::
[
Node
]
,
g_edges
::
[
Edge
]
data
Graph
=
Graph
{
g
raph
_nodes
::
[
Node
]
,
g
raph
_edges
::
[
Edge
]
}
deriving
(
Show
,
Generic
)
$
(
deriveJSON
(
unPrefix
"g_"
)
''
G
raph
)
$
(
deriveJSON
(
unPrefix
"g
raph
_"
)
''
G
raph
)
-----------------------------------------------------------
-- Old Gargantext Version
data
AttributesOld
=
AttributesOld
{
cl
::
Int
}
deriving
(
Show
,
Generic
)
$
(
deriveJSON
(
unPrefix
""
)
''
A
ttributesOld
)
data
NodeOld
=
NodeOld
{
no_id
::
Int
,
no_at
::
AttributesOld
,
no_s
::
Int
,
no_lb
::
Text
}
deriving
(
Show
,
Generic
)
$
(
deriveJSON
(
unPrefix
"no_"
)
''
N
odeOld
)
data
EdgeOld
=
EdgeOld
{
eo_s
::
Int
,
eo_t
::
Int
,
eo_w
::
Text
}
deriving
(
Show
,
Generic
)
$
(
deriveJSON
(
unPrefix
"eo_"
)
''
E
dgeOld
)
data
GraphOld
=
GraphOld
{
go_links
::
[
EdgeOld
]
,
go_nodes
::
[
NodeOld
]
}
deriving
(
Show
,
Generic
)
$
(
deriveJSON
(
unPrefix
"go_"
)
''
G
raphOld
)
----------------------------------------------------------
graphOld2graph
::
GraphOld
->
Graph
graphOld2graph
(
GraphOld
links
nodes
)
=
Graph
(
map
nodeOld2node
nodes
)
(
zipWith
linkOld2edge
[
1
..
]
links
)
where
nodeOld2node
::
NodeOld
->
Node
nodeOld2node
(
NodeOld
no_id'
(
AttributesOld
cl'
)
no_s'
no_lb'
)
=
Node
no_s'
Terms
(
cs
$
show
no_id'
)
no_lb'
(
Attributes
cl'
)
linkOld2edge
::
Int
->
EdgeOld
->
Edge
linkOld2edge
n
(
EdgeOld
eo_s'
eo_t'
eo_w'
)
=
Edge
(
cs
$
show
eo_s'
)
(
cs
$
show
eo_t'
)
((
T
.
read
$
T
.
unpack
eo_w'
)
::
Double
)
(
cs
$
show
n
)
graphOld2graphWithFiles
::
FilePath
->
FilePath
->
IO
()
graphOld2graphWithFiles
g1
g2
=
do
graph
<-
DBL
.
readFile
g1
let
newGraph
=
case
DA
.
decode
graph
::
Maybe
GraphOld
of
Nothing
->
panic
"no graph"
Just
new
->
new
DBL
.
writeFile
g2
(
DA
.
encode
$
graphOld2graph
newGraph
)
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