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
a0a57b4e
Commit
a0a57b4e
authored
Apr 24, 2018
by
Kai Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
merge files
parent
8cce106c
Changes
18
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
774 additions
and
324 deletions
+774
-324
haskell-igraph.cabal
haskell-igraph.cabal
+2
-5
IGraph.hs
src/IGraph.hs
+1
-4
Clique.chs
src/IGraph/Clique.chs
+1
-2
Community.chs
src/IGraph/Community.chs
+1
-3
Generators.chs
src/IGraph/Generators.chs
+25
-5
Internal.chs
src/IGraph/Internal.chs
+505
-0
Arpack.chs
src/IGraph/Internal/Arpack.chs
+0
-13
Attribute.chs
src/IGraph/Internal/Attribute.chs
+0
-50
Graph.chs
src/IGraph/Internal/Graph.chs
+0
-101
Selector.chs
src/IGraph/Internal/Selector.chs
+0
-115
Types.chs
src/IGraph/Internal/Types.chs
+229
-7
Isomorphism.chs
src/IGraph/Isomorphism.chs
+5
-2
Layout.chs
src/IGraph/Layout.chs
+1
-2
Motif.chs
src/IGraph/Motif.chs
+1
-3
Mutable.hs
src/IGraph/Mutable.hs
+1
-4
Structure.chs
src/IGraph/Structure.chs
+1
-5
Types.hs
src/IGraph/Types.hs
+0
-2
Attributes.hs
tests/Test/Attributes.hs
+1
-1
No files found.
haskell-igraph.cabal
View file @
a0a57b4e
...
@@ -27,11 +27,8 @@ library
...
@@ -27,11 +27,8 @@ library
exposed-modules:
exposed-modules:
IGraph.Internal.Initialization
IGraph.Internal.Initialization
IGraph.Internal.Constants
IGraph.Internal.Constants
IGraph.Internal.Arpack
IGraph.Internal.Types
IGraph.Internal.Data
IGraph.Internal
IGraph.Internal.Graph
IGraph.Internal.Attribute
IGraph.Internal.Selector
IGraph
IGraph
IGraph.Types
IGraph.Types
IGraph.Mutable
IGraph.Mutable
...
...
src/IGraph.hs
View file @
a0a57b4e
...
@@ -48,11 +48,8 @@ import Data.Serialize
...
@@ -48,11 +48,8 @@ import Data.Serialize
import
Foreign
(
castPtr
,
with
)
import
Foreign
(
castPtr
,
with
)
import
System.IO.Unsafe
(
unsafePerformIO
)
import
System.IO.Unsafe
(
unsafePerformIO
)
import
IGraph.Internal
.Attribute
import
IGraph.Internal
import
IGraph.Internal.Constants
import
IGraph.Internal.Constants
import
IGraph.Internal.Data
import
IGraph.Internal.Graph
import
IGraph.Internal.Selector
import
IGraph.Mutable
import
IGraph.Mutable
import
IGraph.Types
import
IGraph.Types
...
...
src/IGraph/Clique.chs
View file @
a0a57b4e
...
@@ -13,8 +13,7 @@ import Foreign
...
@@ -13,8 +13,7 @@ import Foreign
import Foreign.C.Types
import Foreign.C.Types
import IGraph
import IGraph
{#import IGraph.Internal.Graph #}
{#import IGraph.Internal #}
{#import IGraph.Internal.Data #}
#include "haskell_igraph.h"
#include "haskell_igraph.h"
...
...
src/IGraph/Community.chs
View file @
a0a57b4e
...
@@ -17,9 +17,7 @@ import Foreign
...
@@ -17,9 +17,7 @@ import Foreign
import Foreign.C.Types
import Foreign.C.Types
import IGraph
import IGraph
{#import IGraph.Internal.Arpack #}
{#import IGraph.Internal #}
{#import IGraph.Internal.Graph #}
{#import IGraph.Internal.Data #}
{#import IGraph.Internal.Constants #}
{#import IGraph.Internal.Constants #}
#include "haskell_igraph.h"
#include "haskell_igraph.h"
...
...
src/IGraph/Generators.hs
→
src/IGraph/Generators.
c
hs
View file @
a0a57b4e
{-# LANGUAGE ForeignFunctionInterface #-}
module IGraph.Generators
module IGraph.Generators
(
ErdosRenyiModel
(
..
)
( full
, ErdosRenyiModel(..)
, erdosRenyiGame
, erdosRenyiGame
, degreeSequenceGame
, degreeSequenceGame
, rewire
, rewire
...
@@ -9,12 +11,21 @@ import Control.Monad (when)
...
@@ -9,12 +11,21 @@ import Control.Monad (when)
import Data.Hashable (Hashable)
import Data.Hashable (Hashable)
import Data.Serialize (Serialize)
import Data.Serialize (Serialize)
import qualified Foreign.Marshal.Utils as C2HSImp
import qualified Foreign.Ptr as C2HSImp
import IGraph
import IGraph
import
IGraph.Internal.Constants
import
IGraph.Internal.Data
import
IGraph.Internal.Graph
import
IGraph.Internal.Initialization
import IGraph.Mutable
import IGraph.Mutable
{#import IGraph.Internal #}
{#import IGraph.Internal.Constants #}
{# import IGraph.Internal.Initialization #}
#include "haskell_igraph.h"
{#fun igraph_full as full
{ allocaIGraph- `IGraph' addIGraphFinalizer*
, `Int', `Bool', `Bool'
} -> `CInt' void- #}
data ErdosRenyiModel = GNP Int Double
data ErdosRenyiModel = GNP Int Double
| GNM Int Int
| GNM Int Int
...
@@ -31,6 +42,10 @@ erdosRenyiGame (GNM n m) d self = do
...
@@ -31,6 +42,10 @@ erdosRenyiGame (GNM n m) d self = do
gp <- igraphInit >> igraphErdosRenyiGame IgraphErdosRenyiGnm n
gp <- igraphInit >> igraphErdosRenyiGame IgraphErdosRenyiGnm n
(fromIntegral m) (isD d) self
(fromIntegral m) (isD d) self
unsafeFreeze $ MLGraph gp
unsafeFreeze $ MLGraph gp
{#fun igraph_erdos_renyi_game as ^
{ allocaIGraph- `IGraph' addIGraphFinalizer*
, `ErdosRenyi', `Int', `Double', `Bool', `Bool'
} -> `CInt' void- #}
-- | Generates a random graph with a given degree sequence.
-- | Generates a random graph with a given degree sequence.
degreeSequenceGame :: [Int] -- ^ Out degree
degreeSequenceGame :: [Int] -- ^ Out degree
...
@@ -41,6 +56,10 @@ degreeSequenceGame out_deg in_deg = do
...
@@ -41,6 +56,10 @@ degreeSequenceGame out_deg in_deg = do
in_deg' <- fromList $ map fromIntegral in_deg
in_deg' <- fromList $ map fromIntegral in_deg
gp <- igraphDegreeSequenceGame out_deg' in_deg' IgraphDegseqSimple
gp <- igraphDegreeSequenceGame out_deg' in_deg' IgraphDegseqSimple
unsafeFreeze $ MLGraph gp
unsafeFreeze $ MLGraph gp
{#fun igraph_degree_sequence_game as ^
{ allocaIGraph- `IGraph' addIGraphFinalizer*
, `Vector', `Vector', `Degseq'
} -> `CInt' void- #}
-- | Randomly rewires a graph while preserving the degree distribution.
-- | Randomly rewires a graph while preserving the degree distribution.
rewire :: (Graph d, Hashable v, Serialize v, Eq v, Serialize e)
rewire :: (Graph d, Hashable v, Serialize v, Eq v, Serialize e)
...
@@ -52,3 +71,4 @@ rewire n gr = do
...
@@ -52,3 +71,4 @@ rewire n gr = do
err <- igraphRewire gptr n IgraphRewiringSimple
err <- igraphRewire gptr n IgraphRewiringSimple
when (err /= 0) $ error "failed to rewire graph!"
when (err /= 0) $ error "failed to rewire graph!"
unsafeFreeze $ MLGraph gptr
unsafeFreeze $ MLGraph gptr
{#fun igraph_rewire as ^ { `IGraph', `Int', `Rewiring' } -> `Int' #}
src/IGraph/Internal
/Data
.chs
→
src/IGraph/Internal.chs
View file @
a0a57b4e
This diff is collapsed.
Click to expand it.
src/IGraph/Internal/Arpack.chs
deleted
100644 → 0
View file @
8cce106c
{-# LANGUAGE ForeignFunctionInterface #-}
module IGraph.Internal.Arpack where
import Control.Monad
import Foreign
import Foreign.C.Types
#include "haskell_igraph.h"
{#pointer *igraph_arpack_options_t as ArpackOpt foreign newtype#}
{#fun igraph_arpack_options_init as igraphArpackNew
{ + } -> `ArpackOpt' #}
src/IGraph/Internal/Attribute.chs
deleted
100644 → 0
View file @
8cce106c
{-# LANGUAGE ForeignFunctionInterface #-}
module IGraph.Internal.Attribute where
import Data.ByteString (packCStringLen)
import Data.ByteString.Unsafe (unsafeUseAsCStringLen)
import Control.Monad
import Control.Applicative
import Data.Serialize (Serialize, decode, encode)
import Foreign
import Foreign.C.Types
import Foreign.C.String
import System.IO.Unsafe (unsafePerformIO)
{#import IGraph.Internal.Graph #}
{#import IGraph.Internal.Data #}
{#import IGraph.Internal.Constants #}
#include "igraph/igraph.h"
#include "haskell_attributes.h"
{#pointer *igraph_attribute_record_t as AttributeRecord foreign newtype#}
withAttr :: String
-> BSVector -> (Ptr AttributeRecord -> IO a) -> IO a
withAttr name bs f = withBSVector bs $ \ptr -> do
fptr <- mallocForeignPtrBytes {#sizeof igraph_attribute_record_t #}
withForeignPtr fptr $ \attr -> withCString name $ \name' -> do
{#set igraph_attribute_record_t.name #} attr name'
{#set igraph_attribute_record_t.type #} attr 2
{#set igraph_attribute_record_t.value #} attr $ castPtr ptr
f attr
{-# INLINE withAttr #-}
{#fun igraph_haskell_attribute_has_attr as ^ { `IGraph', `AttributeElemtype', `String' } -> `Bool' #}
{#fun igraph_haskell_attribute_GAN_set as ^ { `IGraph', `String', `Double' } -> `Int' #}
{#fun igraph_haskell_attribute_GAN as ^ { `IGraph', `String' } -> `Double' #}
{#fun igraph_haskell_attribute_VAS as ^ { `IGraph', `String', `Int' } -> `Ptr BSLen' castPtr #}
{#fun igraph_haskell_attribute_EAN as ^ { `IGraph', `String', `Int' } -> `Double' #}
{#fun igraph_haskell_attribute_EAS as ^ { `IGraph', `String', `Int' } -> `Ptr BSLen' castPtr #}
{#fun igraph_haskell_attribute_EAS_setv as ^ { `IGraph', `String', `BSVector' } -> `Int' #}
{#fun igraph_haskell_attribute_VAS_set as ^ { `IGraph', `String', `Int', castPtr `Ptr BSLen' } -> `Int' #}
{#fun igraph_haskell_attribute_EAS_set as ^ { `IGraph', `String', `Int', castPtr `Ptr BSLen' } -> `Int' #}
src/IGraph/Internal/Graph.chs
deleted
100644 → 0
View file @
8cce106c
{-# LANGUAGE ForeignFunctionInterface #-}
module IGraph.Internal.Graph where
import Control.Monad
import Foreign
import Foreign.C.Types
import System.IO.Unsafe (unsafePerformIO)
import IGraph.Internal.C2HS
{#import IGraph.Internal.Initialization #}
{#import IGraph.Internal.Data #}
{#import IGraph.Internal.Constants #}
#include "haskell_igraph.h"
--------------------------------------------------------------------------------
-- Graph Constructors and Destructors
--------------------------------------------------------------------------------
{#pointer *igraph_t as IGraph foreign finalizer igraph_destroy newtype#}
allocaIGraph :: (Ptr IGraph -> IO a) -> IO a
allocaIGraph f = mallocBytes {# sizeof igraph_t #} >>= f
{-# INLINE allocaIGraph #-}
addIGraphFinalizer :: Ptr IGraph -> IO IGraph
addIGraphFinalizer ptr = do
vec <- newForeignPtr igraph_destroy ptr
return $ IGraph vec
{-# INLINE addIGraphFinalizer #-}
{#fun igraph_empty as igraphNew'
{ allocaIGraph- `IGraph' addIGraphFinalizer*
, `Int', `Bool'
} -> `CInt' void- #}
{#fun igraph_copy as ^
{ allocaIGraph- `IGraph' addIGraphFinalizer*
, `IGraph'
} -> `CInt' void- #}
-- | Create a igraph object and attach a finalizer
igraphNew :: Int -> Bool -> HasInit -> IO IGraph
igraphNew n directed _ = igraphNew' n directed
--------------------------------------------------------------------------------
-- Basic Query Operations
--------------------------------------------------------------------------------
{#fun igraph_vcount as ^ { `IGraph' } -> `Int' #}
{#fun igraph_ecount as ^ { `IGraph' } -> `Int' #}
{#fun igraph_get_eid as ^
{ `IGraph'
, alloca- `Int' peekIntConv*
, `Int'
, `Int'
, `Bool'
, `Bool'
} -> `CInt' void-#}
{#fun igraph_edge as ^
{ `IGraph'
, `Int'
, alloca- `Int' peekIntConv*
, alloca- `Int' peekIntConv*
} -> `CInt' void-#}
-- Adding and Deleting Vertices and Edges
{# fun igraph_add_vertices as ^ { `IGraph', `Int', id `Ptr ()' } -> `()' #}
{# fun igraph_add_edge as ^ { `IGraph', `Int', `Int' } -> `()' #}
-- | The edges are given in a vector, the first two elements define the first
-- edge (the order is from , to for directed graphs). The vector should
-- contain even number of integer numbers between zero and the number of
-- vertices in the graph minus one (inclusive). If you also want to add
-- new vertices, call igraph_add_vertices() first.
{# fun igraph_add_edges as ^
{ `IGraph' -- ^ The graph to which the edges will be added.
, `Vector' -- ^ The edges themselves.
, id `Ptr ()' -- ^ The attributes of the new edges.
} -> `()' #}
-- generators
{#fun igraph_full as ^ { +, `Int', `Bool', `Bool' } -> `IGraph' #}
{#fun igraph_erdos_renyi_game as ^ { +, `ErdosRenyi', `Int', `Double', `Bool'
, `Bool' } -> `IGraph' #}
{#fun igraph_degree_sequence_game as ^ { +, `Vector', `Vector'
, `Degseq' } -> `IGraph' #}
{#fun igraph_rewire as ^ { `IGraph', `Int', `Rewiring' } -> `Int' #}
{#fun igraph_isoclass_create as ^ { +, `Int', `Int', `Bool' } -> `IGraph' #}
src/IGraph/Internal/Selector.chs
deleted
100644 → 0
View file @
8cce106c
{-# 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.Graph #}
{#import IGraph.Internal.Data #}
#include "haskell_igraph.h"
{#pointer *igraph_vs_t as IGraphVs foreign finalizer igraph_vs_destroy newtype #}
{#fun igraph_vs_all as ^ { + } -> `IGraphVs' #}
{#fun igraph_vs_adj as ^ { +, `Int', `Neimode' } -> `IGraphVs' #}
{#fun igraph_vs_vector as ^ { +, `Vector' } -> `IGraphVs' #}
-- Vertex iterator
{#pointer *igraph_vit_t as IGraphVit foreign finalizer igraph_vit_destroy newtype #}
#c
igraph_bool_t igraph_vit_end(igraph_vit_t *vit) {
return IGRAPH_VIT_END(*vit);
}
void igraph_vit_next(igraph_vit_t *vit) {
IGRAPH_VIT_NEXT(*vit);
}
igraph_integer_t igraph_vit_get(igraph_vit_t *vit) {
return IGRAPH_VIT_GET(*vit);
}
#endc
{#fun igraph_vit_create as igraphVitNew { `IGraph', %`IGraphVs', + } -> `IGraphVit' #}
{#fun igraph_vit_end as ^ { `IGraphVit' } -> `Bool' #}
{#fun igraph_vit_next as ^ { `IGraphVit' } -> `()' #}
{#fun igraph_vit_get as ^ { `IGraphVit' } -> `Int' #}
vitToList :: IGraphVit -> IO [Int]
vitToList vit = do
isEnd <- igraphVitEnd vit
if isEnd
then return []
else do
cur <- igraphVitGet vit
igraphVitNext vit
acc <- vitToList vit
return $ cur : acc
-- Edge Selector
{#pointer *igraph_es_t as IGraphEs foreign finalizer igraph_es_destroy newtype #}
{#fun igraph_es_all as ^ { +, `EdgeOrderType' } -> `IGraphEs' #}
{# fun igraph_es_vector as ^ { +, `Vector' } -> `IGraphEs' #}
-- Edge iterator
{#pointer *igraph_eit_t as IGraphEit foreign finalizer igraph_eit_destroy newtype #}
#c
igraph_bool_t igraph_eit_end(igraph_eit_t *eit) {
return IGRAPH_EIT_END(*eit);
}
void igraph_eit_next(igraph_eit_t *eit) {
IGRAPH_EIT_NEXT(*eit);
}
igraph_integer_t igraph_eit_get(igraph_eit_t *eit) {
return IGRAPH_EIT_GET(*eit);
}
#endc
{#fun igraph_eit_create as igraphEitNew { `IGraph', %`IGraphEs', + } -> `IGraphEit' #}
{#fun igraph_eit_end as ^ { `IGraphEit' } -> `Bool' #}
{#fun igraph_eit_next as ^ { `IGraphEit' } -> `()' #}
{#fun igraph_eit_get as ^ { `IGraphEit' } -> `Int' #}
eitToList :: IGraphEit -> IO [Int]
eitToList eit = do
isEnd <- igraphEitEnd eit
if isEnd
then return []
else do
cur <- igraphEitGet eit
igraphEitNext eit
acc <- eitToList eit
return $ cur : acc
-- delete vertices
{# fun igraph_delete_vertices as ^ { `IGraph', %`IGraphVs' } -> `Int' #}
-- delete edges
{# fun igraph_delete_edges as ^ { `IGraph', %`IGraphEs' } -> `Int' #}
src/IGraph/Internal/Types.chs
View file @
a0a57b4e
{-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE ForeignFunctionInterface #-}
module IGraph.Internal.Types where
module IGraph.Internal.Types
( -- * Vector type and basic operations
Vector(..)
, withVector
, allocaVector
, addVectorFinalizer
-- * Pointer vector
, VectorPtr(..)
, withVectorPtr
, allocaVectorPtr
, addVectorPtrFinalizer
-- * String vector
, StrVector(..)
, withStrVector
, allocaStrVector
, addStrVectorFinalizer
-- * Bytestring
, BSLen(..)
-- * Bytestring vector
, BSVector(..)
, withBSVector
, allocaBSVector
, addBSVectorFinalizer
-- * Igraph matrix type
, Matrix(..)
, withMatrix
, allocaMatrix
, addMatrixFinalizer
-- * Igraph vertex selector
, IGraphVs(..)
, withIGraphVs
, allocaVs
, addVsFinalizer
-- * Igraph vertex iterator
, IGraphVit(..)
, withIGraphVit
, allocaVit
, addVitFinalizer
-- * Igraph edge Selector
, IGraphEs
, withIGraphEs
, allocaEs
, addEsFinalizer
-- * Igraph edge iterator
, IGraphEit(..)
, withIGraphEit
, allocaEit
, addEitFinalizer
-- * IGraph type and basic operations
, IGraph(..)
, withIGraph
, allocaIGraph
, addIGraphFinalizer
-- * Igraph attribute record
, AttributeRecord(..)
-- * Igraph arpack options type
, ArpackOpt(..)
, withArpackOpt
, igraphArpackNew
) where
import Control.Monad
import qualified Data.ByteString.Char8 as B
import Data.ByteString (packCStringLen)
import Data.ByteString.Unsafe (unsafeUseAsCStringLen)
import System.IO.Unsafe (unsafePerformIO)
import Data.List (transpose)
import Data.List.Split (chunksOf)
import Data.Serialize (Serialize, decode, encode)
import Foreign
import Foreign.C.Types
import Foreign.C.String
{#import IGraph.Internal.Constants #}
#include "haskell_attributes.h"
#include "haskell_attributes.h"
#include "haskell_igraph.h"
{#pointer *igraph_t as IGraph foreign finalizer igraph_destroy newtype#}
--------------------------------------------------------------------------------
-- Igraph vector
--------------------------------------------------------------------------------
{#pointer *igraph_vector_t as Vector foreign finalizer
{#pointer *igraph_vector_t as Vector foreign finalizer
igraph_vector_destroy newtype#}
igraph_vector_destroy newtype#}
-- Construtors and destructors
allocaVector :: (Ptr Vector -> IO a) -> IO a
allocaVector f = mallocBytes {# sizeof igraph_vector_t #} >>= f
{-# INLINE allocaVector #-}
addVectorFinalizer :: Ptr Vector -> IO Vector
addVectorFinalizer ptr = do
vec <- newForeignPtr igraph_vector_destroy ptr
return $ Vector vec
{-# INLINE addVectorFinalizer #-}
{#pointer *igraph_vector_ptr_t as VectorPtr foreign finalizer
{#pointer *igraph_vector_ptr_t as VectorPtr foreign finalizer
igraph_vector_ptr_destroy_all newtype#}
igraph_vector_ptr_destroy newtype#}
allocaVectorPtr :: (Ptr VectorPtr -> IO a) -> IO a
allocaVectorPtr f = mallocBytes {# sizeof igraph_vector_ptr_t #} >>= f
{-# INLINE allocaVectorPtr #-}
addVectorPtrFinalizer :: Ptr VectorPtr -> IO VectorPtr
addVectorPtrFinalizer ptr = do
vec <- newForeignPtr igraph_vector_ptr_destroy ptr
return $ VectorPtr vec
{-# INLINE addVectorPtrFinalizer #-}
{#pointer *igraph_strvector_t as StrVector foreign finalizer
--------------------------------------------------------------------------------
igraph_strvector_destroy newtype#}
-- Igraph string vector
--------------------------------------------------------------------------------
{#pointer *igraph_strvector_t as StrVector foreign finalizer igraph_strvector_destroy newtype#}
allocaStrVector :: (Ptr StrVector -> IO a) -> IO a
allocaStrVector f = mallocBytes {# sizeof igraph_strvector_t #} >>= f
{-# INLINE allocaStrVector #-}
addStrVectorFinalizer :: Ptr StrVector -> IO StrVector
addStrVectorFinalizer ptr = do
vec <- newForeignPtr igraph_strvector_destroy ptr
return $ StrVector vec
{-# INLINE addStrVectorFinalizer #-}
--------------------------------------------------------------------------------
-- Customized string vector
--------------------------------------------------------------------------------
{#pointer *bytestring_t as BSLen foreign newtype#}
{#pointer *bsvector_t as BSVector foreign finalizer bsvector_destroy newtype#}
{#pointer *bsvector_t as BSVector foreign finalizer bsvector_destroy newtype#}
{#pointer *igraph_matrix_t as Matrix foreign finalizer
allocaBSVector :: (Ptr BSVector -> IO a) -> IO a
igraph_matrix_destroy newtype#}
allocaBSVector f = mallocBytes {# sizeof bsvector_t #} >>= f
{-# INLINE allocaBSVector #-}
addBSVectorFinalizer :: Ptr BSVector -> IO BSVector
addBSVectorFinalizer ptr = do
vec <- newForeignPtr bsvector_destroy ptr
return $ BSVector vec
{-# INLINE addBSVectorFinalizer #-}
{#pointer *igraph_matrix_t as Matrix foreign finalizer igraph_matrix_destroy newtype#}
allocaMatrix :: (Ptr Matrix -> IO a) -> IO a
allocaMatrix f = mallocBytes {# sizeof igraph_matrix_t #} >>= f
{-# INLINE allocaMatrix #-}
addMatrixFinalizer :: Ptr Matrix -> IO Matrix
addMatrixFinalizer ptr = do
vec <- newForeignPtr igraph_matrix_destroy ptr
return $ Matrix vec
{-# INLINE addMatrixFinalizer #-}
{#pointer *igraph_vs_t as IGraphVs foreign finalizer igraph_vs_destroy newtype #}
allocaVs :: (Ptr IGraphVs -> IO a) -> IO a
allocaVs f = mallocBytes {# sizeof igraph_vs_t #} >>= f
{-# INLINE allocaVs #-}
addVsFinalizer :: Ptr IGraphVs -> IO IGraphVs
addVsFinalizer ptr = newForeignPtr igraph_vs_destroy ptr >>= return . IGraphVs
{-# INLINE addVsFinalizer #-}
-- Vertex iterator
{#pointer *igraph_vit_t as IGraphVit foreign finalizer igraph_vit_destroy newtype #}
allocaVit :: (Ptr IGraphVit -> IO a) -> IO a
allocaVit f = mallocBytes {# sizeof igraph_vit_t #} >>= f
{-# INLINE allocaVit #-}
addVitFinalizer :: Ptr IGraphVit -> IO IGraphVit
addVitFinalizer ptr = newForeignPtr igraph_vit_destroy ptr >>= return . IGraphVit
{-# INLINE addVitFinalizer #-}
-- Edge Selector
{#pointer *igraph_es_t as IGraphEs foreign finalizer igraph_es_destroy newtype #}
allocaEs :: (Ptr IGraphEs -> IO a) -> IO a
allocaEs f = mallocBytes {# sizeof igraph_es_t #} >>= f
{-# INLINE allocaEs #-}
addEsFinalizer :: Ptr IGraphEs -> IO IGraphEs
addEsFinalizer ptr = newForeignPtr igraph_es_destroy ptr >>= return . IGraphEs
{-# INLINE addEsFinalizer #-}
-- Edge iterator
{#pointer *igraph_eit_t as IGraphEit foreign finalizer igraph_eit_destroy newtype #}
allocaEit :: (Ptr IGraphEit -> IO a) -> IO a
allocaEit f = mallocBytes {# sizeof igraph_eit_t #} >>= f
{-# INLINE allocaEit #-}
addEitFinalizer :: Ptr IGraphEit -> IO IGraphEit
addEitFinalizer ptr = newForeignPtr igraph_eit_destroy ptr >>= return . IGraphEit
{-# INLINE addEitFinalizer #-}
--------------------------------------------------------------------------------
-- Graph Constructors and Destructors
--------------------------------------------------------------------------------
{#pointer *igraph_t as IGraph foreign finalizer igraph_destroy newtype#}
allocaIGraph :: (Ptr IGraph -> IO a) -> IO a
allocaIGraph f = mallocBytes {# sizeof igraph_t #} >>= f
{-# INLINE allocaIGraph #-}
addIGraphFinalizer :: Ptr IGraph -> IO IGraph
addIGraphFinalizer ptr = do
vec <- newForeignPtr igraph_destroy ptr
return $ IGraph vec
{-# INLINE addIGraphFinalizer #-}
{#pointer *igraph_attribute_record_t as AttributeRecord foreign newtype#}
{#pointer *igraph_arpack_options_t as ArpackOpt foreign newtype#}
{#fun igraph_arpack_options_init as igraphArpackNew
{ + } -> `ArpackOpt' #}
src/IGraph/Isomorphism.chs
View file @
a0a57b4e
...
@@ -15,8 +15,7 @@ import Foreign.C.Types
...
@@ -15,8 +15,7 @@ import Foreign.C.Types
import IGraph
import IGraph
import IGraph.Internal.Initialization (igraphInit)
import IGraph.Internal.Initialization (igraphInit)
import IGraph.Mutable
import IGraph.Mutable
{#import IGraph.Internal.Graph #}
{#import IGraph.Internal #}
{#import IGraph.Internal.Data #}
#include "haskell_igraph.h"
#include "haskell_igraph.h"
...
@@ -60,6 +59,10 @@ isoclassCreate :: Graph d
...
@@ -60,6 +59,10 @@ isoclassCreate :: Graph d
isoclassCreate size idx d = unsafePerformIO $ do
isoclassCreate size idx d = unsafePerformIO $ do
gp <- igraphInit >> igraphIsoclassCreate size idx (isD d)
gp <- igraphInit >> igraphIsoclassCreate size idx (isD d)
unsafeFreeze $ MLGraph gp
unsafeFreeze $ MLGraph gp
{#fun igraph_isoclass_create as ^
{ allocaIGraph- `IGraph' addIGraphFinalizer*
, `Int', `Int', `Bool'
} -> `CInt' void- #}
isoclass3 :: Graph d => d -> [LGraph d () ()]
isoclass3 :: Graph d => d -> [LGraph d () ()]
isoclass3 d = map (flip (isoclassCreate 3) d) n
isoclass3 d = map (flip (isoclassCreate 3) d) n
...
...
src/IGraph/Layout.chs
View file @
a0a57b4e
...
@@ -18,8 +18,7 @@ import Foreign
...
@@ -18,8 +18,7 @@ import Foreign
import Foreign.C.Types
import Foreign.C.Types
import IGraph
import IGraph
{#import IGraph.Internal.Graph #}
{#import IGraph.Internal #}
{#import IGraph.Internal.Data #}
#include "igraph/igraph.h"
#include "igraph/igraph.h"
...
...
src/IGraph/Motif.chs
View file @
a0a57b4e
...
@@ -13,10 +13,8 @@ import Foreign
...
@@ -13,10 +13,8 @@ import Foreign
import Foreign.C.Types
import Foreign.C.Types
import IGraph
import IGraph
{#import IGraph.Internal.Graph #}
{#import IGraph.Internal #}
{#import IGraph.Internal.Selector #}
{#import IGraph.Internal.Constants #}
{#import IGraph.Internal.Constants #}
{#import IGraph.Internal.Data #}
#include "haskell_igraph.h"
#include "haskell_igraph.h"
...
...
src/IGraph/Mutable.hs
View file @
a0a57b4e
...
@@ -15,11 +15,8 @@ import Data.Serialize (Serialize, encode)
...
@@ -15,11 +15,8 @@ import Data.Serialize (Serialize, encode)
import
Foreign
import
Foreign
import
Foreign.C.String
(
CString
,
withCString
)
import
Foreign.C.String
(
CString
,
withCString
)
import
IGraph.Internal.Attribute
import
IGraph.Internal
import
IGraph.Internal.Data
import
IGraph.Internal.Graph
import
IGraph.Internal.Initialization
import
IGraph.Internal.Initialization
import
IGraph.Internal.Selector
import
IGraph.Types
import
IGraph.Types
vertexAttr
::
String
vertexAttr
::
String
...
...
src/IGraph/Structure.chs
View file @
a0a57b4e
...
@@ -22,12 +22,8 @@ import Foreign.C.Types
...
@@ -22,12 +22,8 @@ import Foreign.C.Types
import IGraph
import IGraph
import IGraph.Mutable
import IGraph.Mutable
{#import IGraph.Internal.Graph #}
{#import IGraph.Internal #}
{#import IGraph.Internal.Selector #}
{#import IGraph.Internal.Constants #}
{#import IGraph.Internal.Constants #}
{#import IGraph.Internal.Data #}
{#import IGraph.Internal.Arpack #}
{#import IGraph.Internal.Attribute #}
#include "igraph/igraph.h"
#include "igraph/igraph.h"
...
...
src/IGraph/Types.hs
View file @
a0a57b4e
...
@@ -3,8 +3,6 @@ module IGraph.Types where
...
@@ -3,8 +3,6 @@ module IGraph.Types where
import
qualified
Data.HashMap.Strict
as
M
import
qualified
Data.HashMap.Strict
as
M
import
IGraph.Internal.Graph
type
Node
=
Int
type
Node
=
Int
type
Edge
=
(
Node
,
Node
)
type
Edge
=
(
Node
,
Node
)
type
LEdge
a
=
(
Edge
,
a
)
type
LEdge
a
=
(
Edge
,
a
)
...
...
tests/Test/Attributes.hs
View file @
a0a57b4e
...
@@ -17,7 +17,7 @@ import Test.Utils
...
@@ -17,7 +17,7 @@ import Test.Utils
import
IGraph
import
IGraph
import
IGraph.Exporter.GEXF
import
IGraph.Exporter.GEXF
import
IGraph.Internal
.Attribute
import
IGraph.Internal
import
IGraph.Mutable
import
IGraph.Mutable
import
IGraph.Structure
import
IGraph.Structure
...
...
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