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
4afe752b
Commit
4afe752b
authored
Feb 19, 2016
by
Kai Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add pagerank
parent
ce5e3679
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
6 deletions
+61
-6
Structure.chs.c
cbits/Structure.chs.c
+20
-0
Constants.chs
src/IGraph/Internal/Constants.chs
+14
-6
Structure.chs
src/IGraph/Internal/Structure.chs
+10
-0
Structure.hs
src/IGraph/Structure.hs
+17
-0
No files found.
cbits/Structure.chs.c
View file @
4afe752b
#include "IGraph/Internal/Structure.chs.h"
int
__c2hs_wrapped__igraph_pagerank
(
const
igraph_t
*
graph
,
igraph_pagerank_algo_t
algo
,
igraph_vector_t
*
vector
,
igraph_real_t
*
value
,
const
igraph_vs_t
*
vids
,
igraph_bool_t
directed
,
igraph_real_t
damping
,
const
igraph_vector_t
*
weights
,
void
*
options
)
{
return
igraph_pagerank
(
graph
,
algo
,
vector
,
value
,
*
vids
,
directed
,
damping
,
weights
,
options
);
}
int
__c2hs_wrapped__igraph_induced_subgraph
(
const
igraph_t
*
graph
,
igraph_t
*
res
,
const
igraph_vs_t
*
vids
,
...
...
src/IGraph/Internal/Constants.chs
View file @
4afe752b
...
...
@@ -5,15 +5,23 @@ import Foreign
#include "cbits/haskelligraph.c"
{#enum igraph_neimode_t as Neimode {underscoreToCase} deriving (Show, Eq) #}
{#enum igraph_neimode_t as Neimode {underscoreToCase}
deriving (Show, Eq) #}
{#enum igraph_edgeorder_type_t as EdgeOrderType {underscoreToCase} deriving (Show, Eq) #}
{#enum igraph_edgeorder_type_t as EdgeOrderType {underscoreToCase}
deriving (Show, Eq) #}
{#enum igraph_spincomm_update_t as SpincommUpdate {underscoreToCase} deriving (Show, Eq) #}
{#enum igraph_spincomm_update_t as SpincommUpdate {underscoreToCase}
deriving (Show, Eq) #}
{#enum igraph_spinglass_implementation_t as SpinglassImplementation {underscoreToCase} deriving (Show, Eq) #}
{#enum igraph_spinglass_implementation_t as SpinglassImplementation {underscoreToCase}
deriving (Show, Eq) #}
{#enum igraph_attribute_elemtype_t as AttributeElemtype {underscoreToCase} deriving (Show, Eq) #}
{#enum igraph_attribute_elemtype_t as AttributeElemtype {underscoreToCase}
deriving (Show, Eq) #}
{#enum igraph_subgraph_implementation_t as SubgraphImplementation {underscoreToCase}
deriving (Show, Read, Eq) #}
deriving (Show, Read, Eq) #}
{#enum igraph_pagerank_algo_t as PagerankAlgo {underscoreToCase}
deriving (Show, Read, Eq) #}
src/IGraph/Internal/Structure.chs
View file @
4afe752b
...
...
@@ -38,3 +38,13 @@ import Foreign.C.Types
, `Bool'
, `VectorPtr'
, `ArpackOptPtr' } -> `Int' #}
{#fun igraph_pagerank as ^ { `IGraphPtr'
, `PagerankAlgo'
, `VectorPtr'
, id `Ptr CDouble'
, %`IGraphVsPtr'
, `Bool'
, `Double'
, `VectorPtr'
, id `Ptr ()' } -> `Int' #}
src/IGraph/Structure.hs
View file @
4afe752b
...
...
@@ -3,6 +3,7 @@ module IGraph.Structure
,
closeness
,
betweenness
,
eigenvectorCentrality
,
pagerank
)
where
import
Control.Monad
...
...
@@ -78,3 +79,19 @@ eigenvectorCentrality gr ws = unsafePerformIO $ do
arparck
<-
igraphArpackNew
igraphEigenvectorCentrality
(
_graph
gr
)
vptr
nullPtr
True
True
ws'
arparck
vectorPtrToList
vptr
-- | Google's PageRank
pagerank
::
Graph
d
=>
LGraph
d
v
e
->
Maybe
[
Double
]
->
Double
-- ^ damping factor, usually around 0.85
->
[
Double
]
pagerank
gr
ws
d
=
unsafePerformIO
$
alloca
$
\
p
->
do
vptr
<-
igraphVectorNew
0
vsptr
<-
igraphVsAll
ws'
<-
case
ws
of
Just
w
->
listToVector
w
_
->
liftM
VectorPtr
$
newForeignPtr_
$
castPtr
nullPtr
igraphPagerank
(
_graph
gr
)
IgraphPagerankAlgoPrpack
vptr
p
vsptr
(
isDirected
gr
)
d
ws'
nullPtr
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