packages feed

Etage-Graph 0.1.1 → 0.1.2

raw patch · 2 files changed

+13/−8 lines, 2 filesdep ~Etage-Graph

Dependency ranges changed: Etage-Graph

Files

Etage-Graph.cabal view
@@ -1,5 +1,5 @@ Name:                Etage-Graph-Version:             0.1.1+Version:             0.1.2 Synopsis:            Data-flow based graph algorithms Description:         Data-flow based graph algorithms using the "Control.Etage" framework, showcasing its use for data-flow                      computations. It is meant to be used with the "Data.Graph.Inductive" package which provides graph structures@@ -38,11 +38,12 @@   Build-depends:       base >= 4.3 && < 5,                        fgl >= 5.4.2 && < 5.5,                        random >= 1.0 && < 2,+                       mtl >= 2.0 && < 3,                        containers >= 0.4 && < 1,                        deepseq >= 1.1 && < 2,                        array >= 0.3 && < 1,                        time >= 1.1 && < 2,                        parallel >= 3.1 && < 4,                        Etage == 0.1.8,-                       Etage-Graph == 0.1.1+                       Etage-Graph == 0.1.2   GHC-options:         -Wall -rtsopts -threaded
src/Test.hs view
@@ -9,12 +9,13 @@ import Control.Exception import Control.Monad import Control.Monad.ST+import Control.Monad.Trans import Control.Parallel.Strategies import Data.Array hiding (elems) import Data.Array.ST import Data.Data import Data.Graph.Etage-import Data.Graph.Inductive hiding (edges, defaultGraphSize)+import Data.Graph.Inductive hiding (defaultGraphSize) import qualified Data.Map as M import Data.List import Data.Maybe@@ -77,13 +78,13 @@ generateGraph graphSize = do   when (graphSize < 1) $ throwIO $ AssertionFailed $ "Graph size out of bounds " ++ show graphSize   let ns = map (\n -> (n, show n)) [1..graphSize]-  edges <- fmap concat $ forM [1..graphSize] $ \node -> do+  es <- fmap concat $ forM [1..graphSize] $ \node -> do     nedges <- randomRIO (0, graphSize)     others <- fmap (filter (node /=) . nub) $ forM [1..nedges] $ \_ -> randomRIO (1, graphSize)     gen <- getStdGen     let weights = randomRs (1, 10) gen     return $ zip3 (repeat node) others weights-  return $ mkGraph ns edges+  return $ mkGraph ns es  data TestNeuron a b = TestNeuron Int (Array (Node, Node) (b, [Node])) deriving (Typeable) @@ -175,7 +176,7 @@       writeFile outputDot $ graphviz graph "Etage" (8.27, 11.69) (1, 1) Landscape     _                          -> return ()   -  putStrLn $ "Graph contains " ++ show graphSize ++ " nodes."+  putStrLn $ "Graph contains " ++ show graphSize ++ " nodes and " ++ show (length . edges $ graph) ++ " edges."      before <- getPOSIXTime   let !paths = dijkstraShortestPaths graph graphSize `using` evalTraversable rdeepseq@@ -184,8 +185,11 @@    incubate $ do     nerveTest <- (growNeuron :: NerveOnlyFor (TestNeuron String Double)) (\o -> o { graphSize, knownPaths = paths })-    -- TODO: Also measure network growing time+    before' <- liftIO getPOSIXTime     pathsNerves <- shortestPaths graph+    liftIO $ do+      after' <- getPOSIXTime+      putStrLn $ "Etage graph (external structure) growing time: " ++ show (after' - before')          mapM_ (`attachTo` [TranslatableFor nerveTest]) $ M.elems pathsNerves     @@ -197,5 +201,5 @@ dijkstraShortestPaths :: (Graph gr, Bounded b, Real b, NFData b) => gr a b -> Int -> Array (Node, Node) (b, [Node]) dijkstraShortestPaths graph graphSize = array ((1, 1), (graphSize, graphSize)) $ initialValues ++ concat pathsValues   where initialValues           = [ ((i, j), (maxBound, [])) | i <- [1..graphSize], j <- [1..graphSize] ]-        pathsValues             = map spFromSource (nodes graph) `using` parListChunk (noNodes graph `div` (numCapabilities * 10)) rdeepseq+        pathsValues             = map spFromSource (nodes graph) `using` parListChunk (max 1 $ noNodes graph `div` (numCapabilities * 10)) rdeepseq         spFromSource sourceNode = map (\(LP (n@(node, len):ns)) -> ((sourceNode, node), (len, reverse . map fst $ n:ns))) $ spTree sourceNode graph