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
b9066467
Commit
b9066467
authored
May 31, 2015
by
Kai Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add more functions
parent
12ba3923
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
111 additions
and
1 deletion
+111
-1
igraph.c
cbits/igraph.c
+5
-0
haskell-igraph.cabal
haskell-igraph.cabal
+5
-1
Constants.chs
src/IGraph/Internal/Constants.chs
+9
-0
Selector.chs
src/IGraph/Internal/Selector.chs
+23
-0
Structure.chs
src/IGraph/Internal/Structure.chs
+36
-0
Structure.hs
src/IGraph/Structure.hs
+33
-0
No files found.
cbits/igraph.c
View file @
b9066467
...
@@ -76,3 +76,8 @@ void igraph_arpack_destroy(igraph_arpack_options_t* arpack)
...
@@ -76,3 +76,8 @@ void igraph_arpack_destroy(igraph_arpack_options_t* arpack)
free
(
arpack
);
free
(
arpack
);
arpack
=
NULL
;
arpack
=
NULL
;
}
}
igraph_vs_t
*
igraph_vs_new
()
{
igraph_vs_t
*
vs
=
(
igraph_vs_t
*
)
malloc
(
sizeof
(
igraph_vs_t
));
return
vs
;
}
haskell-igraph.cabal
View file @
b9066467
...
@@ -17,17 +17,21 @@ cabal-version: >=1.10
...
@@ -17,17 +17,21 @@ cabal-version: >=1.10
library
library
exposed-modules:
exposed-modules:
IGraph.Internal.Arpack
IGraph.Internal.Initialization
IGraph.Internal.Initialization
IGraph.Internal.Constants
IGraph.Internal.Arpack
IGraph.Internal.Data
IGraph.Internal.Data
IGraph.Internal.Graph
IGraph.Internal.Graph
IGraph.Internal.Attribute
IGraph.Internal.Attribute
IGraph.Internal.Selector
IGraph.Internal.Structure
IGraph.Internal.Generator
IGraph.Internal.Generator
IGraph.Internal.Clique
IGraph.Internal.Clique
IGraph.Internal.Community
IGraph.Internal.Community
IGraph
IGraph
IGraph.Mutable
IGraph.Mutable
IGraph.Clique
IGraph.Clique
IGraph.Structure
IGraph.Community
IGraph.Community
IGraph.Read
IGraph.Read
-- other-modules:
-- other-modules:
...
...
src/IGraph/Internal/Constants.chs
0 → 100644
View file @
b9066467
{-# LANGUAGE ForeignFunctionInterface #-}
module IGraph.Internal.Constants where
import Foreign
#include "igraph/igraph.h"
#include "cbits/igraph.c"
{#enum igraph_neimode_t as IGraphNeimode {underscoreToCase} deriving (Show, Eq) #}
src/IGraph/Internal/Selector.chs
0 → 100644
View file @
b9066467
{-# LANGUAGE ForeignFunctionInterface #-}
module IGraph.Internal.Selector where
import Control.Monad
import Foreign
import Foreign.C.Types
import System.IO.Unsafe (unsafePerformIO)
{#import IGraph.Internal.Constants #}
{#import IGraph.Internal.Data #}
#include "igraph/igraph.h"
#include "cbits/igraph.c"
{#pointer *igraph_vs_t as IGraphVsPtr foreign finalizer igraph_vs_destroy newtype #}
{#fun igraph_vs_new as ^ { } -> `IGraphVsPtr' #}
{#fun igraph_vs_all as ^ { `IGraphVsPtr' } -> `Int' #}
{#fun igraph_vs_adj as ^ { `IGraphVsPtr', `Int', `IGraphNeimode' } -> `Int' #}
{#fun igraph_vs_vector as ^ { `IGraphVsPtr', `VectorPtr' } -> `Int' #}
src/IGraph/Internal/Structure.chs
0 → 100644
View file @
b9066467
{-# LANGUAGE ForeignFunctionInterface #-}
module IGraph.Internal.Structure where
import Foreign
import Foreign.C.Types
{#import IGraph.Internal.Graph #}
{#import IGraph.Internal.Selector #}
{#import IGraph.Internal.Constants #}
{#import IGraph.Internal.Data #}
{#import IGraph.Internal.Arpack #}
#include "igraph/igraph.h"
#include "cbits/igraph.c"
{#fun igraph_closeness as ^ { `IGraphPtr'
, `VectorPtr'
, %`IGraphVsPtr'
, `IGraphNeimode'
, `VectorPtr'
, `Bool' } -> `Int' #}
{#fun igraph_betweenness as ^ { `IGraphPtr'
, id `Ptr VectorPtr'
, %`IGraphVsPtr'
, `Bool'
, id `Ptr VectorPtr'
, `Bool' } -> `Int' #}
{#fun igraph_eigenvector_centrality as ^ { `IGraphPtr'
, id `Ptr VectorPtr'
, id `Ptr CDouble'
, `Bool'
, `Bool'
, id `Ptr VectorPtr'
, `ArpackOptPtr' } -> `Int' #}
src/IGraph/Structure.hs
0 → 100644
View file @
b9066467
module
IGraph.Structure
(
closeness
)
where
import
Control.Monad
import
Foreign
import
Foreign.C.Types
import
System.IO.Unsafe
(
unsafePerformIO
)
import
IGraph
import
IGraph.Mutable
(
U
)
import
IGraph.Internal.Data
import
IGraph.Internal.Selector
import
IGraph.Internal.Structure
import
IGraph.Internal.Arpack
import
IGraph.Internal.Constants
closeness
::
[
Int
]
-- ^ vertices
->
LGraph
d
v
e
->
Maybe
[
Double
]
-- ^ optional edge weights
->
IGraphNeimode
->
Bool
-- ^ whether to normalize
->
[
Double
]
closeness
vs
(
LGraph
g
)
ws
mode
normal
=
unsafePerformIO
$
do
vsptr
<-
igraphVsNew
vs'
<-
listToVector
$
map
fromIntegral
vs
igraphVsVector
vsptr
vs'
vptr
<-
igraphVectorNew
0
ws'
<-
case
ws
of
Just
w
->
listToVector
w
_
->
liftM
VectorPtr
$
newForeignPtr_
$
castPtr
nullPtr
igraphCloseness
g
vptr
vsptr
mode
ws'
normal
vectorPtrToList
vptr
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