Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
haskell-igraph
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
haskell-igraph
Commits
54994870
Commit
54994870
authored
Jun 30, 2015
by
Kai Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bump bytestring-lexing version to 0.5
parent
1f2f2294
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
6 deletions
+13
-6
haskell-igraph.cabal
haskell-igraph.cabal
+1
-1
Read.hs
src/IGraph/Read.hs
+12
-5
No files found.
haskell-igraph.cabal
View file @
54994870
...
...
@@ -40,7 +40,7 @@ library
build-depends:
base >=4.0 && <5.0
, bytestring >=0.9
, bytestring-lexing
, bytestring-lexing
>=0.5
, primitive
, unordered-containers
, hashable
...
...
src/IGraph/Read.hs
View file @
54994870
module
IGraph.Read
where
module
IGraph.Read
(
readAdjMatrix
,
readAdjMatrixWeighted
)
where
import
qualified
Data.ByteString.Char8
as
B
import
Data.ByteString.Lex.
Double
(
readDouble
)
import
Data.Maybe
import
Data.ByteString.Lex.
Fractional
(
readSigned
,
readExponential
)
import
Data.Maybe
(
fromJust
)
import
IGraph
readDouble
::
B
.
ByteString
->
Double
readDouble
=
fst
.
fromJust
.
readSigned
readExponential
{-# INLINE readDouble #-}
readAdjMatrix
::
Graph
d
=>
FilePath
->
IO
(
LGraph
d
B
.
ByteString
()
)
readAdjMatrix
fl
=
do
c
<-
B
.
readFile
fl
let
(
header
:
xs
)
=
B
.
lines
c
mat
=
map
(
map
(
fst
.
fromJust
.
readDouble
)
.
B
.
words
)
xs
mat
=
map
(
map
readDouble
.
B
.
words
)
xs
es
=
fst
$
unzip
$
filter
f
$
zip
[
(
i
,
j
)
|
i
<-
[
0
..
nrow
-
1
],
j
<-
[
0
..
nrow
-
1
]
]
$
concat
mat
nrow
=
length
mat
ncol
=
length
$
head
mat
...
...
@@ -24,7 +31,7 @@ readAdjMatrixWeighted :: Graph d => FilePath -> IO (LGraph d B.ByteString Double
readAdjMatrixWeighted
fl
=
do
c
<-
B
.
readFile
fl
let
(
header
:
xs
)
=
B
.
lines
c
mat
=
map
(
map
(
fst
.
fromJust
.
readDouble
)
.
B
.
words
)
xs
mat
=
map
(
map
readDouble
.
B
.
words
)
xs
(
es
,
ws
)
=
unzip
$
filter
f
$
zip
[
(
i
,
j
)
|
i
<-
[
0
..
nrow
-
1
],
j
<-
[
0
..
nrow
-
1
]
]
$
concat
mat
nrow
=
length
mat
ncol
=
length
$
head
mat
...
...
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