{-| Module : FiniteCategories Description : Examples of random composition graphs. Copyright : Guillaume Sabbagh 2021 License : GPL-3 Maintainer : guillaumesabbagh@protonmail.com Stability : experimental Portability : portable This example shows how to use `mkRandomCompositionGraph`. -} module ExampleRandomCompositionGraph.ExampleRandomCompositionGraph ( main ) where import CompositionGraph.CompositionGraph import RandomCompositionGraph.RandomCompositionGraph import System.Random import ExportGraphViz.ExportGraphViz generateRGCs :: (RandomGen g) => Int -> g -> [CompositionGraph Int Int] -> ([CompositionGraph Int Int], g) generateRGCs 0 gen cgs = (cgs,gen) generateRGCs n gen cgs = ((newCG:end), finalGen) where (newCG,newGen) = (mkRandomCompositionGraph 10 15 5 gen) (end,finalGen) = generateRGCs (n-1) newGen cgs exportRCG :: [CompositionGraph Int Int] -> IO () exportRCG [] = putStrLn "End of ExampleRandomCompositionGraph" exportRCG (cg:cgs) = do putStrLn (show (length cgs)++" rcg remaining...") catToPdf cg ("OutputGraphViz/Examples/RandomCompositionGraph/RCG"++show (length cgs)) exportRCG cgs -- | Exports 10 random composition graphs as pdf. main = do putStrLn "Start of ExampleRandomCompositionGraph" exportRCG cgs where (cgs, g) = generateRGCs 10 (mkStdGen 745678765434567) []