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
2
Merge Requests
2
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
8cce106c
Commit
8cce106c
authored
7 years ago
by
Kai Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
merge some files
parent
70148846
No related merge requests found
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
218 additions
and
256 deletions
+218
-256
haskell-igraph.cabal
haskell-igraph.cabal
+7
-13
Clique.chs
src/IGraph/Clique.chs
+12
-2
Community.chs
src/IGraph/Community.chs
+52
-5
Clique.chs
src/IGraph/Internal/Clique.chs
+0
-17
Community.chs
src/IGraph/Internal/Community.chs
+0
-55
Isomorphism.chs
src/IGraph/Internal/Isomorphism.chs
+0
-18
Layout.chs
src/IGraph/Internal/Layout.chs
+0
-38
Motif.chs
src/IGraph/Internal/Motif.chs
+0
-20
Structure.chs
src/IGraph/Internal/Structure.chs
+0
-61
Types.chs
src/IGraph/Internal/Types.chs
+20
-0
Isomorphism.chs
src/IGraph/Isomorphism.chs
+14
-5
Layout.chs
src/IGraph/Layout.chs
+35
-3
Motif.chs
src/IGraph/Motif.chs
+18
-2
Mutable.hs
src/IGraph/Mutable.hs
+0
-10
Structure.chs
src/IGraph/Structure.chs
+60
-7
No files found.
haskell-igraph.cabal
View file @
8cce106c
...
...
@@ -25,6 +25,13 @@ Flag graphics
library
exposed-modules:
IGraph.Internal.Initialization
IGraph.Internal.Constants
IGraph.Internal.Arpack
IGraph.Internal.Data
IGraph.Internal.Graph
IGraph.Internal.Attribute
IGraph.Internal.Selector
IGraph
IGraph.Types
IGraph.Mutable
...
...
@@ -37,19 +44,6 @@ library
IGraph.Layout
IGraph.Generators
IGraph.Exporter.GEXF
IGraph.Internal.Initialization
IGraph.Internal.Constants
IGraph.Internal.Arpack
IGraph.Internal.Data
IGraph.Internal.Graph
IGraph.Internal.Attribute
IGraph.Internal.Isomorphism
IGraph.Internal.Selector
IGraph.Internal.Structure
IGraph.Internal.Motif
IGraph.Internal.Clique
IGraph.Internal.Community
IGraph.Internal.Layout
other-modules:
IGraph.Internal.C2HS
...
...
This diff is collapsed.
Click to expand it.
src/IGraph/Clique.hs
→
src/IGraph/Clique.
c
hs
View file @
8cce106c
{-# LANGUAGE ForeignFunctionInterface #-}
module IGraph.Clique
( cliques
, maximalCliques
...
...
@@ -6,9 +7,16 @@ module IGraph.Clique
import Control.Applicative ((<$>))
import System.IO.Unsafe (unsafePerformIO)
import qualified Foreign.Marshal.Utils as C2HSImp
import qualified Foreign.Ptr as C2HSImp
import Foreign
import Foreign.C.Types
import IGraph
import
IGraph.Internal.Clique
import
IGraph.Internal.Data
{#import IGraph.Internal.Graph #}
{#import IGraph.Internal.Data #}
#include "haskell_igraph.h"
cliques :: LGraph d v e
-> (Int, Int) -- ^ Minimum and maximum size of the cliques to be returned.
...
...
@@ -18,6 +26,7 @@ cliques gr (lo, hi) = unsafePerformIO $ do
vpptr <- igraphVectorPtrNew 0
_ <- igraphCliques (_graph gr) vpptr lo hi
(map.map) truncate <$> toLists vpptr
{#fun igraph_cliques as ^ { `IGraph', `VectorPtr', `Int', `Int' } -> `Int' #}
maximalCliques :: LGraph d v e
-> (Int, Int) -- ^ Minimum and maximum size of the cliques to be returned.
...
...
@@ -27,3 +36,4 @@ maximalCliques gr (lo, hi) = unsafePerformIO $ do
vpptr <- igraphVectorPtrNew 0
_ <- igraphMaximalCliques (_graph gr) vpptr lo hi
(map.map) truncate <$> toLists vpptr
{#fun igraph_maximal_cliques as ^ { `IGraph', `VectorPtr', `Int', `Int' } -> `Int' #}
This diff is collapsed.
Click to expand it.
src/IGraph/Community.hs
→
src/IGraph/Community.
c
hs
View file @
8cce106c
{-# LANGUAGE ForeignFunctionInterface #-}
module IGraph.Community
( CommunityOpt(..)
, CommunityMethod(..)
...
...
@@ -10,15 +11,18 @@ import Data.Default.Class
import Data.Function (on)
import Data.List
import Data.Ord
import System.IO.Unsafe (unsafePerformIO)
import Foreign
import Foreign.C.Types
import
System.IO.Unsafe
(
unsafePerformIO
)
import IGraph
import
IGraph.Internal.Arpack
import
IGraph.Internal.Community
import
IGraph.Internal.Constants
import
IGraph.Internal.Data
{#import IGraph.Internal.Arpack #}
{#import IGraph.Internal.Graph #}
{#import IGraph.Internal.Data #}
{#import IGraph.Internal.Constants #}
#include "haskell_igraph.h"
data CommunityOpt = CommunityOpt
{ _method :: CommunityMethod
...
...
@@ -69,3 +73,46 @@ findCommunity gr opt = unsafePerformIO $ do
liftM ( map (fst . unzip) . groupBy ((==) `on` snd)
. sortBy (comparing snd) . zip [0..] ) $ toList result
{#fun igraph_community_spinglass as ^
{ `IGraph'
, `Vector'
, id `Ptr CDouble'
, id `Ptr CDouble'
, `Vector'
, id `Ptr Vector'
, `Int'
, `Bool'
, `Double'
, `Double'
, `Double'
, `SpincommUpdate'
, `Double'
, `SpinglassImplementation'
, `Double'
} -> `Int' #}
{#fun igraph_community_leading_eigenvector as ^
{ `IGraph'
, `Vector'
, id `Ptr Matrix'
, `Vector'
, `Int'
, `ArpackOpt'
, id `Ptr CDouble'
, `Bool'
, id `Ptr Vector'
, id `Ptr VectorPtr'
, id `Ptr Vector'
, id `T'
, id `Ptr ()'
} -> `Int' #}
type T = FunPtr ( Ptr Vector
-> CLong
-> CDouble
-> Ptr Vector
-> FunPtr (Ptr CDouble -> Ptr CDouble -> CInt -> Ptr () -> IO CInt)
-> Ptr ()
-> Ptr ()
-> IO CInt)
This diff is collapsed.
Click to expand it.
src/IGraph/Internal/Clique.chs
deleted
100644 → 0
View file @
70148846
{-# LANGUAGE ForeignFunctionInterface #-}
module IGraph.Internal.Clique where
import qualified Foreign.Marshal.Utils as C2HSImp
import qualified Foreign.Ptr as C2HSImp
import Foreign
import Foreign.C.Types
{#import IGraph.Internal.Graph #}
{#import IGraph.Internal.Data #}
#include "haskell_igraph.h"
{#fun igraph_cliques as ^ { `IGraph', `VectorPtr', `Int', `Int' } -> `Int' #}
{#fun igraph_maximal_cliques as ^ { `IGraph', `VectorPtr', `Int', `Int' } -> `Int' #}
This diff is collapsed.
Click to expand it.
src/IGraph/Internal/Community.chs
deleted
100644 → 0
View file @
70148846
{-# LANGUAGE ForeignFunctionInterface #-}
module IGraph.Internal.Community where
import Foreign
import Foreign.C.Types
{#import IGraph.Internal.Arpack #}
{#import IGraph.Internal.Graph #}
{#import IGraph.Internal.Data #}
{#import IGraph.Internal.Constants #}
#include "haskell_igraph.h"
{#fun igraph_community_spinglass as ^
{ `IGraph'
, `Vector'
, id `Ptr CDouble'
, id `Ptr CDouble'
, `Vector'
, id `Ptr Vector'
, `Int'
, `Bool'
, `Double'
, `Double'
, `Double'
, `SpincommUpdate'
, `Double'
, `SpinglassImplementation'
, `Double'
} -> `Int' #}
{#fun igraph_community_leading_eigenvector as ^
{ `IGraph'
, `Vector'
, id `Ptr Matrix'
, `Vector'
, `Int'
, `ArpackOpt'
, id `Ptr CDouble'
, `Bool'
, id `Ptr Vector'
, id `Ptr VectorPtr'
, id `Ptr Vector'
, id `T'
, id `Ptr ()'
} -> `Int' #}
type T = FunPtr ( Ptr Vector
-> CLong
-> CDouble
-> Ptr Vector
-> FunPtr (Ptr CDouble -> Ptr CDouble -> CInt -> Ptr () -> IO CInt)
-> Ptr ()
-> Ptr ()
-> IO CInt)
This diff is collapsed.
Click to expand it.
src/IGraph/Internal/Isomorphism.chs
deleted
100644 → 0
View file @
70148846
{-# LANGUAGE ForeignFunctionInterface #-}
module IGraph.Internal.Isomorphism where
import Foreign
import Foreign.C.Types
{#import IGraph.Internal.Graph #}
{#import IGraph.Internal.Data #}
#include "haskell_igraph.h"
{#fun igraph_get_subisomorphisms_vf2 as ^ { `IGraph', `IGraph',
id `Ptr ()', id `Ptr ()', id `Ptr ()', id `Ptr ()', `VectorPtr',
id `FunPtr (Ptr IGraph -> Ptr IGraph -> CInt -> CInt -> Ptr () -> IO CInt)',
id `FunPtr (Ptr IGraph -> Ptr IGraph -> CInt -> CInt -> Ptr () -> IO CInt)',
id `Ptr ()'} -> `Int' #}
{#fun igraph_isomorphic as ^ { `IGraph', `IGraph', id `Ptr CInt' } -> `Int' #}
This diff is collapsed.
Click to expand it.
src/IGraph/Internal/Layout.chs
deleted
100644 → 0
View file @
70148846
{-# LANGUAGE ForeignFunctionInterface #-}
module IGraph.Internal.Layout where
import qualified Foreign.Marshal.Utils as C2HSImp
import qualified Foreign.Ptr as C2HSImp
import Foreign
import Foreign.C.Types
{#import IGraph.Internal.Graph #}
{#import IGraph.Internal.Data #}
#include "igraph/igraph.h"
{#fun igraph_layout_kamada_kawai as ^ { `IGraph'
, `Matrix'
, `Int'
, `Double'
, `Double'
, `Double'
, `Double'
, `Bool'
, id `Ptr Vector'
, id `Ptr Vector'
, id `Ptr Vector'
, id `Ptr Vector'
} -> `Int' #}
{# fun igraph_layout_lgl as ^ { `IGraph'
, `Matrix'
, `Int'
, `Double'
, `Double'
, `Double'
, `Double'
, `Double'
, `Int'
} -> `Int' #}
This diff is collapsed.
Click to expand it.
src/IGraph/Internal/Motif.chs
deleted
100644 → 0
View file @
70148846
{-# LANGUAGE ForeignFunctionInterface #-}
module IGraph.Internal.Motif where
import qualified Foreign.Marshal.Utils as C2HSImp
import qualified Foreign.Ptr as C2HSImp
import Foreign
import Foreign.C.Types
{#import IGraph.Internal.Graph #}
{#import IGraph.Internal.Selector #}
{#import IGraph.Internal.Constants #}
{#import IGraph.Internal.Data #}
#include "haskell_igraph.h"
{#fun igraph_triad_census as ^ { `IGraph'
, `Vector' } -> `Int' #}
{#fun igraph_motifs_randesu as ^ { `IGraph', `Vector', `Int'
, `Vector' } -> `Int' #}
This diff is collapsed.
Click to expand it.
src/IGraph/Internal/Structure.chs
deleted
100644 → 0
View file @
70148846
{-# 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"
{#fun igraph_induced_subgraph as ^ { `IGraph'
, +160
, %`IGraphVs'
, `SubgraphImplementation' } -> `IGraph' #}
{#fun igraph_closeness as ^ { `IGraph'
, `Vector'
, %`IGraphVs'
, `Neimode'
, `Vector'
, `Bool' } -> `Int' #}
{#fun igraph_betweenness as ^ { `IGraph'
, `Vector'
, %`IGraphVs'
, `Bool'
, `Vector'
, `Bool' } -> `Int' #}
{#fun igraph_eigenvector_centrality as ^ { `IGraph'
, `Vector'
, id `Ptr CDouble'
, `Bool'
, `Bool'
, `Vector'
, `ArpackOpt' } -> `Int' #}
{#fun igraph_pagerank as ^ { `IGraph'
, `PagerankAlgo'
, `Vector'
, id `Ptr CDouble'
, %`IGraphVs'
, `Bool'
, `Double'
, `Vector'
, id `Ptr ()' } -> `Int' #}
{#fun igraph_personalized_pagerank as ^ { `IGraph'
, `PagerankAlgo'
, `Vector'
, id `Ptr CDouble'
, %`IGraphVs'
, `Bool'
, `Double'
, `Vector'
, `Vector'
, id `Ptr ()' } -> `Int' #}
This diff is collapsed.
Click to expand it.
src/IGraph/Internal/Types.chs
0 → 100644
View file @
8cce106c
{-# LANGUAGE ForeignFunctionInterface #-}
module IGraph.Internal.Types where
#include "haskell_attributes.h"
{#pointer *igraph_t as IGraph foreign finalizer igraph_destroy newtype#}
{#pointer *igraph_vector_t as Vector foreign finalizer
igraph_vector_destroy newtype#}
{#pointer *igraph_vector_ptr_t as VectorPtr foreign finalizer
igraph_vector_ptr_destroy_all newtype#}
{#pointer *igraph_strvector_t as StrVector foreign finalizer
igraph_strvector_destroy newtype#}
{#pointer *bsvector_t as BSVector foreign finalizer bsvector_destroy newtype#}
{#pointer *igraph_matrix_t as Matrix foreign finalizer
igraph_matrix_destroy newtype#}
This diff is collapsed.
Click to expand it.
src/IGraph/Isomorphism.hs
→
src/IGraph/Isomorphism.
c
hs
View file @
8cce106c
{-# LANGUAGE ForeignFunctionInterface #-}
module IGraph.Isomorphism
( getSubisomorphisms
, isomorphic
...
...
@@ -6,16 +7,18 @@ module IGraph.Isomorphism
, isoclass4
) where
import
Foreign
import
Foreign.C.Types
import System.IO.Unsafe (unsafePerformIO)
import Foreign
import Foreign.C.Types
import IGraph
import
IGraph.Internal.Data
import
IGraph.Internal.Graph
import IGraph.Internal.Initialization (igraphInit)
import
IGraph.Internal.Isomorphism
import IGraph.Mutable
{#import IGraph.Internal.Graph #}
{#import IGraph.Internal.Data #}
#include "haskell_igraph.h"
getSubisomorphisms :: Graph d
=> LGraph d v1 e1 -- ^ graph to be searched in
...
...
@@ -30,6 +33,11 @@ getSubisomorphisms g1 g2 = unsafePerformIO $ do
gptr1 = _graph g1
gptr2 = _graph g2
{-# INLINE getSubisomorphisms #-}
{#fun igraph_get_subisomorphisms_vf2 as ^ { `IGraph', `IGraph',
id `Ptr ()', id `Ptr ()', id `Ptr ()', id `Ptr ()', `VectorPtr',
id `FunPtr (Ptr IGraph -> Ptr IGraph -> CInt -> CInt -> Ptr () -> IO CInt)',
id `FunPtr (Ptr IGraph -> Ptr IGraph -> CInt -> CInt -> Ptr () -> IO CInt)',
id `Ptr ()'} -> `Int' #}
-- | Determine whether two graphs are isomorphic.
isomorphic :: Graph d
...
...
@@ -40,6 +48,7 @@ isomorphic g1 g2 = unsafePerformIO $ alloca $ \ptr -> do
_ <- igraphIsomorphic (_graph g1) (_graph g2) ptr
x <- peek ptr
return (x /= 0)
{#fun igraph_isomorphic as ^ { `IGraph', `IGraph', id `Ptr CInt' } -> `Int' #}
-- | Creates a graph from the given isomorphism class.
-- This function is implemented only for graphs with three or four vertices.
...
...
This diff is collapsed.
Click to expand it.
src/IGraph/Layout.hs
→
src/IGraph/Layout.
c
hs
View file @
8cce106c
{-# LANGUAGE ForeignFunctionInterface #-}
module IGraph.Layout
( getLayout
, LayoutMethod(..)
...
...
@@ -11,10 +12,16 @@ import Data.Maybe (isJust)
import Foreign (nullPtr)
import System.IO.Unsafe (unsafePerformIO)
import qualified Foreign.Marshal.Utils as C2HSImp
import qualified Foreign.Ptr as C2HSImp
import Foreign
import Foreign.C.Types
import IGraph
import
IGraph.Internal.Clique
import
IGraph.Internal.Data
import
IGraph.Internal.Layout
{#import IGraph.Internal.Graph #}
{#import IGraph.Internal.Data #}
#include "igraph/igraph.h"
data LayoutMethod =
KamadaKawai { kk_seed :: !(Maybe [(Double, Double)])
...
...
@@ -84,3 +91,28 @@ getLayout gr method = do
where
n = nNodes gr
gptr = _graph gr
{#fun igraph_layout_kamada_kawai as ^ { `IGraph'
, `Matrix'
, `Int'
, `Double'
, `Double'
, `Double'
, `Double'
, `Bool'
, id `Ptr Vector'
, id `Ptr Vector'
, id `Ptr Vector'
, id `Ptr Vector'
} -> `Int' #}
{# fun igraph_layout_lgl as ^ { `IGraph'
, `Matrix'
, `Int'
, `Double'
, `Double'
, `Double'
, `Double'
, `Double'
, `Int'
} -> `Int' #}
This diff is collapsed.
Click to expand it.
src/IGraph/Motif.hs
→
src/IGraph/Motif.
c
hs
View file @
8cce106c
{-# LANGUAGE ForeignFunctionInterface #-}
module IGraph.Motif
( triad
, triadCensus
...
...
@@ -6,9 +7,18 @@ module IGraph.Motif
import Data.Hashable (Hashable)
import System.IO.Unsafe (unsafePerformIO)
import qualified Foreign.Marshal.Utils as C2HSImp
import qualified Foreign.Ptr as C2HSImp
import Foreign
import Foreign.C.Types
import IGraph
import
IGraph.Internal.Motif
import
IGraph.Internal.Data
{#import IGraph.Internal.Graph #}
{#import IGraph.Internal.Selector #}
{#import IGraph.Internal.Constants #}
{#import IGraph.Internal.Data #}
#include "haskell_igraph.h"
-- | Every triple of vertices in a directed graph
-- 003: A, B, C, the empty graph.
...
...
@@ -58,3 +68,9 @@ triadCensus gr = unsafePerformIO $ do
map truncate <$> toList vptr
-- motifsRandesu
{#fun igraph_triad_census as ^ { `IGraph'
, `Vector' } -> `Int' #}
{#fun igraph_motifs_randesu as ^ { `IGraph', `Vector', `Int'
, `Vector' } -> `Int' #}
This diff is collapsed.
Click to expand it.
src/IGraph/Mutable.hs
View file @
8cce106c
...
...
@@ -6,8 +6,6 @@ module IGraph.Mutable
,
setNodeAttr
,
edgeAttr
,
vertexAttr
,
withVertexAttr
,
withEdgeAttr
)
where
import
Control.Monad
(
when
,
forM
)
...
...
@@ -30,14 +28,6 @@ vertexAttr = "vertex_attribute"
edgeAttr
::
String
edgeAttr
=
"edge_attribute"
withVertexAttr
::
(
CString
->
IO
a
)
->
IO
a
withVertexAttr
=
withCString
vertexAttr
{-# INLINE withVertexAttr #-}
withEdgeAttr
::
(
CString
->
IO
a
)
->
IO
a
withEdgeAttr
=
withCString
edgeAttr
{-# INLINE withEdgeAttr #-}
-- | Mutable labeled graph.
newtype
MLGraph
m
d
v
e
=
MLGraph
IGraph
...
...
This diff is collapsed.
Click to expand it.
src/IGraph/Structure.hs
→
src/IGraph/Structure.
c
hs
View file @
8cce106c
{-# LANGUAGE ForeignFunctionInterface #-}
module IGraph.Structure
( inducedSubgraph
, closeness
...
...
@@ -16,15 +17,19 @@ import Foreign
import Foreign.C.Types
import System.IO.Unsafe (unsafePerformIO)
import Foreign
import Foreign.C.Types
import IGraph
import
IGraph.Internal.Arpack
import
IGraph.Internal.Attribute
import
IGraph.Internal.Constants
import
IGraph.Internal.Data
import
IGraph.Internal.Graph
import
IGraph.Internal.Selector
import
IGraph.Internal.Structure
import IGraph.Mutable
{#import IGraph.Internal.Graph #}
{#import IGraph.Internal.Selector #}
{#import IGraph.Internal.Constants #}
{#import IGraph.Internal.Data #}
{#import IGraph.Internal.Arpack #}
{#import IGraph.Internal.Attribute #}
#include "igraph/igraph.h"
inducedSubgraph :: (Hashable v, Eq v, Serialize v) => LGraph d v e -> [Int] -> LGraph d v e
inducedSubgraph gr vs = unsafePerformIO $ do
...
...
@@ -130,3 +135,51 @@ personalizedPagerank gr reset ws d
where
n = nNodes gr
m = nEdges gr
{#fun igraph_induced_subgraph as ^ { `IGraph'
, +160
, %`IGraphVs'
, `SubgraphImplementation' } -> `IGraph' #}
{#fun igraph_closeness as ^ { `IGraph'
, `Vector'
, %`IGraphVs'
, `Neimode'
, `Vector'
, `Bool' } -> `Int' #}
{#fun igraph_betweenness as ^ { `IGraph'
, `Vector'
, %`IGraphVs'
, `Bool'
, `Vector'
, `Bool' } -> `Int' #}
{#fun igraph_eigenvector_centrality as ^ { `IGraph'
, `Vector'
, id `Ptr CDouble'
, `Bool'
, `Bool'
, `Vector'
, `ArpackOpt' } -> `Int' #}
{#fun igraph_pagerank as ^ { `IGraph'
, `PagerankAlgo'
, `Vector'
, id `Ptr CDouble'
, %`IGraphVs'
, `Bool'
, `Double'
, `Vector'
, id `Ptr ()' } -> `Int' #}
{#fun igraph_personalized_pagerank as ^ { `IGraph'
, `PagerankAlgo'
, `Vector'
, id `Ptr CDouble'
, %`IGraphVs'
, `Bool'
, `Double'
, `Vector'
, `Vector'
, id `Ptr ()' } -> `Int' #}
This diff is collapsed.
Click to expand it.
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