packages feed

haskell-igraph 0.1.0 → 0.2.0

raw patch · 15 files changed

+38/−144 lines, 15 files

Files

LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) 2015 Kai Zhang+Copyright (c) 2016 Kai Zhang  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the
− cbits/Selector.chs.c
@@ -1,21 +0,0 @@-#include "IGraph/Internal/Selector.chs.h"-igraph_vit_t * __c2hs_wrapped__igraph_vit_new(const igraph_t * graph,-                                              igraph_vs_t * vs)-{-    return igraph_vit_new(graph, *vs);-}-igraph_eit_t * __c2hs_wrapped__igraph_eit_new(const igraph_t * graph,-                                              igraph_es_t * es)-{-    return igraph_eit_new(graph, *es);-}-int __c2hs_wrapped__igraph_delete_vertices(igraph_t * graph,-                                           const igraph_vs_t * vertices)-{-    return igraph_delete_vertices(graph, *vertices);-}-int __c2hs_wrapped__igraph_delete_edges(igraph_t * graph,-                                        igraph_es_t * edges)-{-    return igraph_delete_edges(graph, *edges);-}
− cbits/Structure.chs.c
@@ -1,78 +0,0 @@-#include "IGraph/Internal/Structure.chs.h"-int __c2hs_wrapped__igraph_personalized_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,-                                                 igraph_vector_t * reset,-                                                 const igraph_vector_t * weights,-                                                 void * options)-{-    return igraph_personalized_pagerank(graph,-                                        algo,-                                        vector,-                                        value,-                                        *vids,-                                        directed,-                                        damping,-                                        reset,-                                        weights,-                                        options);-}-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,-                                            igraph_subgraph_implementation_t impl)-{-    return igraph_induced_subgraph(graph, res, *vids, impl);-}-int __c2hs_wrapped__igraph_closeness(const igraph_t * graph,-                                     igraph_vector_t * res,-                                     const igraph_vs_t * vids,-                                     igraph_neimode_t mode,-                                     const igraph_vector_t * weights,-                                     igraph_bool_t normalized)-{-    return igraph_closeness(graph,-                            res,-                            *vids,-                            mode,-                            weights,-                            normalized);-}-int __c2hs_wrapped__igraph_betweenness(const igraph_t * graph,-                                       igraph_vector_t * res,-                                       const igraph_vs_t * vids,-                                       igraph_bool_t directed,-                                       const igraph_vector_t * weights,-                                       igraph_bool_t nobigint)-{-    return igraph_betweenness(graph,-                              res,-                              *vids,-                              directed,-                              weights,-                              nobigint);-}
cbits/haskelligraph.c view
@@ -1,6 +1,3 @@-#ifndef HASKELL_IGRAPH-#define HASKELL_IGRAPH- #include <igraph/igraph.h>  igraph_integer_t igraph_get_eid_(igraph_t* graph, igraph_integer_t pfrom, igraph_integer_t pto,@@ -37,6 +34,3 @@   /* attach attribute table */   igraph_i_set_attribute_table(&igraph_cattribute_table); }---#endif
haskell-igraph.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                haskell-igraph-version:             0.1.0+version:             0.2.0 synopsis:            Imcomplete igraph bindings description:         This is an attempt to create a complete bindings for the                      igraph<"http://igraph.org/c/"> library. Related work:@@ -14,7 +14,7 @@ copyright:           (c) 2016 Kai Zhang category:            Math build-type:          Simple-cabal-version:       >=1.22+cabal-version:       >=1.24  Flag graphics   Description: Enable graphics output@@ -69,10 +69,9 @@   hs-source-dirs:      src   default-language:    Haskell2010   build-tools:         c2hs >=0.25.0-  C-Sources:-    cbits/haskelligraph.c-    cbits/Selector.chs.c-    cbits/Structure.chs.c+  c-sources:           cbits/haskelligraph.c+  include-dirs:        cbits+  includes:            cbits/haskelligraph.h  test-suite tests   type: exitcode-stdio-1.0
src/IGraph/Internal/Arpack.chs view
@@ -5,7 +5,7 @@ import Foreign import Foreign.C.Types -#include "cbits/haskelligraph.c"+#include "haskelligraph.h"  {#pointer *igraph_arpack_options_t as ArpackOptPtr foreign finalizer igraph_arpack_destroy newtype#} 
src/IGraph/Internal/Clique.chs view
@@ -10,7 +10,7 @@ {#import IGraph.Internal.Graph #} {#import IGraph.Internal.Data #} -#include "cbits/haskelligraph.c"+#include "igraph/igraph.h"  {#fun igraph_cliques as ^ { `IGraphPtr', `VectorPPtr', `Int', `Int' } -> `Int' #} 
src/IGraph/Internal/Community.chs view
@@ -9,7 +9,7 @@ {#import IGraph.Internal.Data #} {#import IGraph.Internal.Constants #} -#include "cbits/haskelligraph.c"+#include "igraph/igraph.h"  {#fun igraph_community_spinglass as ^ { `IGraphPtr'
src/IGraph/Internal/Constants.chs view
@@ -3,7 +3,7 @@  import Foreign -#include "cbits/haskelligraph.c"+#include "igraph/igraph.h"  {#enum igraph_neimode_t as Neimode {underscoreToCase}     deriving (Show, Eq) #}
src/IGraph/Internal/Data.chs view
@@ -10,7 +10,7 @@ import Data.List (transpose) import Data.List.Split (chunksOf) -#include "cbits/haskelligraph.c"+#include "haskelligraph.h"  {#pointer *igraph_vector_t as VectorPtr foreign finalizer igraph_vector_destroy newtype#} 
src/IGraph/Internal/Graph.chs view
@@ -10,7 +10,7 @@ {#import IGraph.Internal.Data #} {#import IGraph.Internal.Constants #} -#include "cbits/haskelligraph.c"+#include "haskelligraph.h"  {#pointer *igraph_t as IGraphPtr foreign finalizer igraph_destroy newtype#} 
src/IGraph/Internal/Initialization.chs view
@@ -1,7 +1,7 @@ {-# LANGUAGE ForeignFunctionInterface #-} module IGraph.Internal.Initialization where -#include "cbits/haskelligraph.c"+#include "haskelligraph.h"  data HasInit 
src/IGraph/Layout.hs view
@@ -16,27 +16,27 @@ import           IGraph.Internal.Data import           IGraph.Internal.Layout -data LayoutMethod = KamadaKawai-    { kk_seed      :: !(Maybe [(Double, Double)])-    , kk_nIter     :: !Int-    , kk_sigma     :: (Int -> Double) -- ^ The base standard deviation of position-                                  -- change proposals-    , kk_startTemp :: !Double  -- ^ The initial temperature for the annealing-    , kk_coolFact  :: !Double  -- ^ The cooling factor for the simulated annealing-    , kk_const     :: (Int -> Double)  -- ^ The Kamada-Kawai vertex attraction constant-    }-                  | LGL   -- ^ the Large Graph Layout algorithm-    { lgl_nIter      :: !Int-    , lgl_maxdelta   :: (Int -> Double)  -- ^ The maximum length of the move allowed for-                               -- a vertex in a single iteration.-                               -- A reasonable default is the number of vertices.-    , lgl_area       :: (Int -> Double)  -- ^ This parameter gives the area of the square-                           -- on which the vertices will be placed. A reasonable-                           -- default value is the number of vertices squared.-    , lgl_coolexp    :: !Double  -- ^ The cooling exponent. A reasonable default value is 1.5.-    , lgl_repulserad :: (Int -> Double) -- ^ Determines the radius at which vertex-vertex repulsion cancels out attraction of adjacent vertices. A reasonable default value is area times the number of vertices.-    , lgl_cellsize   :: (Int -> Double)-    }+data LayoutMethod =+    KamadaKawai { kk_seed      :: !(Maybe [(Double, Double)])+                , kk_nIter     :: !Int+                , kk_sigma     :: (Int -> Double) -- ^ The base standard deviation of+                -- position change proposals+                , kk_startTemp :: !Double  -- ^ The initial temperature for the annealing+                , kk_coolFact  :: !Double  -- ^ The cooling factor for the simulated annealing+                , kk_const     :: (Int -> Double)  -- ^ The Kamada-Kawai vertex attraction constant+                }+  | LGL { lgl_nIter      :: !Int+        , lgl_maxdelta   :: (Int -> Double)  -- ^ The maximum length of the move allowed+        -- for a vertex in a single iteration. A reasonable default is the number of vertices.+        , lgl_area       :: (Int -> Double)  -- ^ This parameter gives the area+        -- of the square on which the vertices will be placed. A reasonable+        -- default value is the number of vertices squared.+        , lgl_coolexp    :: !Double  -- ^ The cooling exponent. A reasonable default value is 1.5.+        , lgl_repulserad :: (Int -> Double) -- ^ Determines the radius at which+        -- vertex-vertex repulsion cancels out attraction of adjacent vertices.+        -- A reasonable default value is area times the number of vertices.+        , lgl_cellsize   :: (Int -> Double)+        }  defaultKamadaKawai :: LayoutMethod defaultKamadaKawai = KamadaKawai
tests/Test/Basic.hs view
@@ -28,14 +28,14 @@     ]   where     edgeList = sort $ unsafePerformIO $ randEdges 1000 100-    gr = mkGraph (100,Nothing) (edgeList, Nothing) :: LGraph D () ()-    simple = mkGraph (3,Nothing) ([(0,1),(1,2),(2,0)],Nothing) :: LGraph D () ()+    gr = mkGraph (replicate 100 ()) $ zip edgeList $ repeat () :: LGraph D () ()+    simple = mkGraph (replicate 3 ()) $ zip [(0,1),(1,2),(2,0)] $ repeat () :: LGraph D () ()  graphEdit :: TestTree graphEdit = testGroup "Graph editing"     [ testCase "" $ [(1,2)] @=? (sort $ edges simple') ]   where-    simple = mkGraph (3,Nothing) ([(0,1),(1,2),(2,0)],Nothing) :: LGraph U () ()+    simple = mkGraph (replicate 3 ()) $ zip [(0,1),(1,2),(2,0)] $ repeat () :: LGraph U () ()     simple' = runST $ do         g <- thaw simple         delEdges [(0,1),(0,2)] g
tests/Test/Structure.hs view
@@ -27,7 +27,7 @@             , ["a","c"], [("a","c"), ("c","a")] )     test (ori,ns,expect) = sort expect @=? sort result       where-        gr = fromLabeledEdges ori :: LGraph D String ()+        gr = fromLabeledEdges $ zip ori $ repeat () :: LGraph D String ()         ns' = map (head . getNodes gr) ns         gr' = inducedSubgraph gr ns'         result = map (nodeLab gr' *** nodeLab gr') $ edges gr'