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
e69dabde
Commit
e69dabde
authored
Oct 11, 2021
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'alp/toGraph' of
ssh://delanoe.org/gargantext-graph
parents
66b97882
927ecc2d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
3 deletions
+33
-3
CSV.hs
src/Graph/Tools/CSV.hs
+33
-3
No files found.
src/Graph/Tools/CSV.hs
View file @
e69dabde
...
...
@@ -29,6 +29,9 @@ import qualified Data.Graph.Inductive.PatriciaTree as DGIP
import
qualified
Data.List
as
List
import
qualified
Data.Set
as
Set
import
qualified
Data.Vector
as
Vector
import
Data.Semigroup
import
qualified
Data.IntMap.Strict
as
IntMap
import
Data.Maybe
(
fromJust
)
------------------------------------------------------------------------
-- | Clean tools
...
...
@@ -59,15 +62,42 @@ data FileGraph = CillexGraph | TestGraph | SnapGraph
readFileGraph
::
FileGraph
->
FilePath
->
IO
(
DGIP
.
Gr
[
Text
]
Double
)
readFileGraph
CillexGraph
fp
=
toGraph
<$>
snd
<$>
readFileCsvCillex
fp
readFileGraph
TestGraph
fp
=
toGraph
<$>
snd
<$>
readFileCsvTest
fp
readFileGraph
SnapGraph
fp
=
toGraph
<$>
snd
<$>
readFileSnapCsv
fp
-- readFileGraph SnapGraph fp = toGraph <$> snd <$> readFileSnapCsv fp
readFileGraph
SnapGraph
fp
=
toGraph''
<$>
snd
<$>
readFileSnapCsv
fp
toGraph''
::
Vector
SnapCsv
->
DGIP
.
Gr
[
Text
]
Double
toGraph''
v
=
DGI
.
undir
(
DGI
.
mkGraph
ns
es'
)
where
es
=
List
.
map
(
\
(
SnapCsv
f
t
)
->
(
f
,
t
))
$
Vector
.
toList
v
(
_
,
nodeDict
)
=
List
.
foldl'
(
\
(
nextIdx
,
dict
)
(
from
,
to
)
->
let
(
nextIdx1
,
dict1
)
=
smartInsert
nextIdx
from
dict
in
smartInsert
nextIdx1
to
dict1
)
(
0
,
mempty
)
es
es'
=
List
.
map
(
\
(
f
,
t
)
->
(
fromJust
(
IntMap
.
lookup
f
nodeDict
)
,
fromJust
(
IntMap
.
lookup
t
nodeDict
)
,
1
)
)
es
ns
=
List
.
map
(
\
(
a
,
b
)
->
(
b
,
[
Protolude
.
show
a
]))
(
IntMap
.
toList
nodeDict
)
smartInsert
nextI
v
dict
=
case
IntMap
.
lookup
v
dict
of
Nothing
->
(
nextI
+
1
,
IntMap
.
insert
v
nextI
dict
)
Just
i
->
(
nextI
,
dict
)
toGraph
::
ToNode
a
=>
Vector
a
->
(
DGIP
.
Gr
[
Text
]
Double
)
toGraph
vs
=
DGI
.
mkGraph
ns
(
uniq'
$
List
.
concat
es
)
toGraph
vs
=
g
where
(
ns
,
es
)
=
List
.
unzip
$
Vector
.
toList
$
Vector
.
map
toNode
vs
g
=
DGI
.
mkGraph
ns
(
uniq'
$
List
.
concat
es
)
------------------------------------------------------------------------
class
ToNode
a
where
...
...
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