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
c6136304
Commit
c6136304
authored
May 31, 2015
by
Kai Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refinement
parent
565fc95d
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
21 additions
and
48 deletions
+21
-48
haskelligraph.c
cbits/haskelligraph.c
+0
-14
Clique.hs
src/IGraph/Clique.hs
+4
-2
Community.hs
src/IGraph/Community.hs
+8
-12
Community.chs
src/IGraph/Internal/Community.chs
+4
-4
Data.chs
src/IGraph/Internal/Data.chs
+3
-14
Mutable.hs
src/IGraph/Mutable.hs
+2
-2
No files found.
cbits/haskelligraph.c
View file @
c6136304
...
@@ -3,20 +3,6 @@
...
@@ -3,20 +3,6 @@
#include <igraph/igraph.h>
#include <igraph/igraph.h>
igraph_vector_t
*
igraph_vector_new
(
long
int
size
)
{
igraph_vector_t
*
vector
=
(
igraph_vector_t
*
)
malloc
(
sizeof
(
igraph_vector_t
));
igraph_vector_init
(
vector
,
size
);
return
vector
;
}
igraph_vector_ptr_t
*
igraph_vector_ptr_new
(
long
int
size
)
{
igraph_vector_ptr_t
*
vptr
=
(
igraph_vector_ptr_t
*
)
malloc
(
sizeof
(
igraph_vector_ptr_t
));
igraph_vector_ptr_init
(
vptr
,
size
);
return
vptr
;
}
igraph_strvector_t
*
igraph_strvector_new
(
long
int
size
)
igraph_strvector_t
*
igraph_strvector_new
(
long
int
size
)
{
{
igraph_strvector_t
*
vector
=
(
igraph_strvector_t
*
)
malloc
(
sizeof
(
igraph_strvector_t
));
igraph_strvector_t
*
vector
=
(
igraph_strvector_t
*
)
malloc
(
sizeof
(
igraph_strvector_t
));
...
...
src/IGraph/Clique.hs
View file @
c6136304
...
@@ -14,7 +14,8 @@ cliques :: (Int, Int) -- ^ Minimum and maximum size of the cliques to be return
...
@@ -14,7 +14,8 @@ cliques :: (Int, Int) -- ^ Minimum and maximum size of the cliques to be return
-- No bound will be used if negative or zero
-- No bound will be used if negative or zero
->
LGraph
d
v
e
->
LGraph
d
v
e
->
[[
Int
]]
-- ^ cliques represented by node ids
->
[[
Int
]]
-- ^ cliques represented by node ids
cliques
(
lo
,
hi
)
(
LGraph
g
)
=
unsafePerformIO
$
allocaVectorP
$
\
vpptr
->
do
cliques
(
lo
,
hi
)
(
LGraph
g
)
=
unsafePerformIO
$
do
vpptr
<-
igraphVectorPtrNew
0
_
<-
igraphCliques
g
vpptr
lo
hi
_
<-
igraphCliques
g
vpptr
lo
hi
(
map
.
map
)
truncate
<$>
vectorPPtrToList
vpptr
(
map
.
map
)
truncate
<$>
vectorPPtrToList
vpptr
...
@@ -22,6 +23,7 @@ maximalCliques :: (Int, Int) -- ^ Minimum and maximum size of the cliques to be
...
@@ -22,6 +23,7 @@ maximalCliques :: (Int, Int) -- ^ Minimum and maximum size of the cliques to be
-- No bound will be used if negative or zero
-- No bound will be used if negative or zero
->
LGraph
d
v
e
->
LGraph
d
v
e
->
[[
Int
]]
-- ^ cliques represented by node ids
->
[[
Int
]]
-- ^ cliques represented by node ids
maximalCliques
(
lo
,
hi
)
(
LGraph
g
)
=
unsafePerformIO
$
allocaVectorP
$
\
vpptr
->
do
maximalCliques
(
lo
,
hi
)
(
LGraph
g
)
=
unsafePerformIO
$
do
vpptr
<-
igraphVectorPtrNew
0
_
<-
igraphMaximalCliques
g
vpptr
lo
hi
_
<-
igraphMaximalCliques
g
vpptr
lo
hi
(
map
.
map
)
truncate
<$>
vectorPPtrToList
vpptr
(
map
.
map
)
truncate
<$>
vectorPPtrToList
vpptr
src/IGraph/Community.hs
View file @
c6136304
...
@@ -22,18 +22,14 @@ communityLeadingEigenvector :: LGraph U v e
...
@@ -22,18 +22,14 @@ communityLeadingEigenvector :: LGraph U v e
->
Int
-- ^ number of steps
->
Int
-- ^ number of steps
->
[[
Int
]]
->
[[
Int
]]
communityLeadingEigenvector
g
@
(
LGraph
gr
)
ws
step
=
unsafePerformIO
$
do
communityLeadingEigenvector
g
@
(
LGraph
gr
)
ws
step
=
unsafePerformIO
$
do
arparck
<-
igraphArpackNew
ap
<-
igraphArpackNew
vec
<-
igraphVectorNew
0
vptr
<-
igraphVectorNew
0
withArpackOptPtr
arparck
$
\
ap
->
withVectorPtr
vec
$
\
vptr
->
case
ws
of
wptr
<-
case
ws
of
Just
xs
->
do
Just
w
->
listToVector
w
ws'
<-
listToVector
xs
_
->
liftM
VectorPtr
$
newForeignPtr_
$
castPtr
nullPtr
withVectorPtr
ws'
$
\
wptr
->
igraphCommunityLeadingEigenvector
gr
wptr
nullPtr
vptr
step
ap
nullPtr
igraphCommunityLeadingEigenvector
gr
wptr
nullPtr
vptr
step
ap
nullPtr
False
nullPtr
nullPtr
nullPtr
nullFunPtr
nullPtr
False
nullPtr
nullPtr
nullPtr
nullFunPtr
nullPtr
xs
<-
vectorPtrToList
vptr
_
->
igraphCommunityLeadingEigenvector
gr
nullPtr
nullPtr
vptr
step
ap
nullPtr
False
nullPtr
nullPtr
nullPtr
nullFunPtr
nullPtr
xs
<-
vectorPtrToList
vec
return
$
map
f
$
groupBy
((
==
)
`
on
`
snd
)
$
sortBy
(
comparing
snd
)
$
zip
[
0
..
]
xs
return
$
map
f
$
groupBy
((
==
)
`
on
`
snd
)
$
sortBy
(
comparing
snd
)
$
zip
[
0
..
]
xs
where
where
f
=
fst
.
unzip
f
=
fst
.
unzip
src/IGraph/Internal/Community.chs
View file @
c6136304
...
@@ -11,15 +11,15 @@ import Foreign.C.Types
...
@@ -11,15 +11,15 @@ import Foreign.C.Types
#include "cbits/haskelligraph.c"
#include "cbits/haskelligraph.c"
{#fun igraph_community_leading_eigenvector as ^ { `IGraphPtr'
{#fun igraph_community_leading_eigenvector as ^ { `IGraphPtr'
,
id `Ptr
VectorPtr'
,
`
VectorPtr'
, id `Ptr MatrixPtr'
, id `Ptr MatrixPtr'
,
id `Ptr
VectorPtr'
,
`
VectorPtr'
, `Int'
, `Int'
,
id `Ptr
ArpackOptPtr'
,
`
ArpackOptPtr'
, id `Ptr CDouble'
, id `Ptr CDouble'
, `Bool'
, `Bool'
, id `Ptr VectorPtr'
, id `Ptr VectorPtr'
,
`
VectorPPtr'
,
id `Ptr
VectorPPtr'
, id `Ptr VectorPtr'
, id `Ptr VectorPtr'
, id `T'
, id `T'
, id `Ptr ()'
, id `Ptr ()'
...
...
src/IGraph/Internal/Data.chs
View file @
c6136304
...
@@ -14,7 +14,7 @@ import System.IO.Unsafe (unsafePerformIO)
...
@@ -14,7 +14,7 @@ import System.IO.Unsafe (unsafePerformIO)
-- Construtors and destructors
-- Construtors and destructors
{#fun igraph_vector_
new as ^ {
`Int' } -> `VectorPtr' #}
{#fun igraph_vector_
init as igraphVectorNew { +,
`Int' } -> `VectorPtr' #}
listToVector :: [Double] -> IO VectorPtr
listToVector :: [Double] -> IO VectorPtr
listToVector xs = do
listToVector xs = do
...
@@ -55,13 +55,9 @@ vectorPtrToList vptr = do
...
@@ -55,13 +55,9 @@ vectorPtrToList vptr = do
{#fun igraph_vector_size as ^ { `VectorPtr' } -> `Int' #}
{#fun igraph_vector_size as ^ { `VectorPtr' } -> `Int' #}
data VectorP
{#pointer *igraph_vector_ptr_t as VectorPPtr foreign finalizer igraph_vector_ptr_destroy_all newtype#}
{#pointer *igraph_vector_ptr_t as VectorPPtr -> VectorP #}
{#fun igraph_vector_ptr_new as ^ { `Int' } -> `VectorPPtr' #}
{#fun igraph_vector_ptr_init as igraphVectorPtrNew { +, `Int' } -> `VectorPPtr' #}
{#fun igraph_vector_ptr_destroy as ^ { `VectorPPtr' } -> `()' #}
{#fun igraph_vector_ptr_destroy_all as ^ { `VectorPPtr' } -> `()' #}
{#fun igraph_vector_ptr_e as ^ { `VectorPPtr', `Int' } -> `Ptr ()' #}
{#fun igraph_vector_ptr_e as ^ { `VectorPPtr', `Int' } -> `Ptr ()' #}
{#fun igraph_vector_ptr_set as ^ { `VectorPPtr', `Int', id `Ptr ()' } -> `()' #}
{#fun igraph_vector_ptr_set as ^ { `VectorPPtr', `Int', id `Ptr ()' } -> `()' #}
...
@@ -83,13 +79,6 @@ vectorPPtrToList vpptr = do
...
@@ -83,13 +79,6 @@ vectorPPtrToList vpptr = do
fptr <- newForeignPtr_ $ castPtr vptr
fptr <- newForeignPtr_ $ castPtr vptr
vectorPtrToList $ VectorPtr fptr
vectorPtrToList $ VectorPtr fptr
allocaVectorP :: (VectorPPtr -> IO b) -> IO b
allocaVectorP fn = do
vptr <- igraphVectorPtrNew 0
r <- fn vptr
igraphVectorPtrDestroyAll vptr
return r
data StrVector
data StrVector
{#pointer *igraph_strvector_t as StrVectorPtr -> StrVector #}
{#pointer *igraph_strvector_t as StrVectorPtr -> StrVector #}
...
...
src/IGraph/Mutable.hs
View file @
c6136304
...
@@ -50,7 +50,7 @@ instance MGraph MLGraph U where
...
@@ -50,7 +50,7 @@ instance MGraph MLGraph U where
alloca
$
\
ptr
->
do
alloca
$
\
ptr
->
do
poke
ptr
attr
poke
ptr
attr
vptr
<-
listToVectorP
[
castPtr
ptr
]
vptr
<-
listToVectorP
[
castPtr
ptr
]
igraphAddVertices
g
n
(
castPtr
vptr
)
withVectorPPtr
vptr
$
\
p
->
igraphAddVertices
g
n
$
castPtr
p
addEdges
es
(
MLGraph
g
)
=
unsafePrimToPrim
$
do
addEdges
es
(
MLGraph
g
)
=
unsafePrimToPrim
$
do
vec
<-
listToVector
xs
vec
<-
listToVector
xs
...
@@ -64,6 +64,6 @@ instance MGraph MLGraph U where
...
@@ -64,6 +64,6 @@ instance MGraph MLGraph U where
alloca
$
\
ptr
->
do
alloca
$
\
ptr
->
do
poke
ptr
attr
poke
ptr
attr
vptr
<-
listToVectorP
[
castPtr
ptr
]
vptr
<-
listToVectorP
[
castPtr
ptr
]
igraphAddEdges
g
vec
(
castPtr
vptr
)
withVectorPPtr
vptr
$
\
p
->
igraphAddEdges
g
vec
$
castPtr
p
where
where
(
xs
,
vs
)
=
unzip
$
map
(
\
(
a
,
b
,
v
)
->
([
fromIntegral
a
,
fromIntegral
b
],
v
)
)
es
(
xs
,
vs
)
=
unzip
$
map
(
\
(
a
,
b
,
v
)
->
([
fromIntegral
a
,
fromIntegral
b
],
v
)
)
es
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