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
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
gargantext
haskell-igraph
Commits
d868daf3
Commit
d868daf3
authored
Jun 05, 2015
by
Kai Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix a bug in Read.hs
parent
b3220726
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
19 deletions
+20
-19
Data.chs
src/IGraph/Internal/Data.chs
+7
-2
Layout.hs
src/IGraph/Layout.hs
+1
-1
Read.hs
src/IGraph/Read.hs
+4
-4
test.hs
test.hs
+8
-12
No files found.
src/IGraph/Internal/Data.chs
View file @
d868daf3
...
...
@@ -123,6 +123,7 @@ listToStrVector xs = do
{#fun igraph_matrix_ncol as ^ { `MatrixPtr' } -> `Int' #}
-- row lists to matrix
listsToMatrixPtr :: [[Double]] -> IO MatrixPtr
listsToMatrixPtr xs = do
mptr <- igraphMatrixNew r c
...
...
@@ -134,11 +135,15 @@ listsToMatrixPtr xs = do
r = length xs
c = maximum $ map length xs
-- to row lists
matrixPtrToLists :: MatrixPtr -> IO [[Double]]
matrixPtrToLists mptr = do
matrixPtrToLists = liftM transpose . matrixPtrToColumnLists
matrixPtrToColumnLists :: MatrixPtr -> IO [[Double]]
matrixPtrToColumnLists mptr = do
r <- igraphMatrixNrow mptr
c <- igraphMatrixNcol mptr
xs <- allocaArray (r*c) $ \ptr -> do
igraphMatrixCopyTo mptr ptr
peekArray (r*c) ptr
return $
transpose $
chunksOf r $ map realToFrac xs
return $ chunksOf r $ map realToFrac xs
src/IGraph/Layout.hs
View file @
d868daf3
...
...
@@ -27,7 +27,7 @@ kamadaKawai :: Graph d => LGraph d v e -> Double -> Double -> Double -> Double -
kamadaKawai
gr
sigma
initemp
coolexp
kkconst
opt
=
unsafePerformIO
$
do
mptr
<-
mat
igraphLayoutKamadaKawai
(
_graph
gr
)
mptr
(
_nIter
opt
)
sigma
initemp
coolexp
kkconst
useSeed
nullPtr
nullPtr
nullPtr
nullPtr
[
x
,
y
]
<-
matrixPtrToLists
mptr
[
x
,
y
]
<-
matrixPtrTo
Column
Lists
mptr
return
$
zip
x
y
where
(
useSeed
,
mat
)
=
case
_seed
opt
of
...
...
src/IGraph/Read.hs
View file @
d868daf3
...
...
@@ -11,25 +11,25 @@ readAdjMatrix fl = do
c
<-
B
.
readFile
fl
let
(
header
:
xs
)
=
B
.
lines
c
mat
=
map
(
map
(
fst
.
fromJust
.
readDouble
)
.
B
.
words
)
xs
es
=
fst
$
unzip
$
filter
f
$
zip
[
(
i
,
j
)
|
i
<-
[
0
..
nrow
-
1
],
j
<-
[
i
..
nrow
-
1
]
]
$
concat
mat
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
if
nrow
/=
ncol
then
error
"nrow != ncol"
else
return
$
mkGraph
(
nrow
,
Just
$
B
.
words
header
)
(
es
,
Nothing
)
where
f
((
i
,
j
),
v
)
=
i
/=
j
&&
v
/=
0
f
((
i
,
j
),
v
)
=
i
<
j
&&
v
/=
0
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
(
es
,
ws
)
=
unzip
$
filter
f
$
zip
[
(
i
,
j
)
|
i
<-
[
0
..
nrow
-
1
],
j
<-
[
i
..
nrow
-
1
]
]
$
concat
mat
(
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
if
nrow
/=
ncol
then
error
"nrow != ncol"
else
return
$
mkGraph
(
nrow
,
Just
$
B
.
words
header
)
(
es
,
Just
ws
)
where
f
((
i
,
j
),
v
)
=
i
/=
j
&&
v
/=
0
f
((
i
,
j
),
v
)
=
i
<
j
&&
v
/=
0
test.hs
View file @
d868daf3
...
...
@@ -18,15 +18,11 @@ import System.Environment
main
=
do
[
fl
]
<-
getArgs
g
<-
readAdjMatrix
fl
::
IO
(
LGraph
U
B
.
ByteString
()
)
let
n
=
nNodes
g
r
=
map
(
f
g
)
[
0
..
n
-
1
]
mapM_
h
r
where
f
g
i
=
let
name
=
nodeLab
g
i
xs
=
map
(
nodeLab
g
)
$
neighbors
g
i
in
(
name
,
B
.
intercalate
","
xs
)
h
(
a
,
b
)
=
do
B
.
putStr
a
B
.
putStr
"
\t
"
B
.
putStrLn
b
g
<-
readAdjMatrixWeighted
fl
::
IO
(
LGraph
U
B
.
ByteString
Double
)
let
m
=
_labelToNode
g
[
a
]
=
M
.
lookupDefault
[]
"H3K27ac"
m
[
b
]
=
M
.
lookupDefault
[]
"H3K4me1"
m
ws
=
Just
$
map
(
abs
.
edgeLabByEid
g
)
[
0
..
nEdges
g
-
1
]
cs
=
(
map
.
map
)
(
nodeLab
g
)
$
communityLeadingEigenvector
g
ws
10000
print
$
edgeLab
g
(
b
,
a
)
mapM_
print
cs
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