Safe Haskell | None |
---|---|
Language | Haskell2010 |
Implementations of binomially random graphs, as described by Erdős and Rényi.
Graphs generated using this method have a constant edge probability between two nodes.
See Erdős and A. Rényi, On Random Graphs, Publ. Math. 6, 290 (1959).
graph-generators copyright: Copyright (C) 2014 Uli Köhler
NetworkX copyright: Copyright (C) 2004-2010 by Aric Hagberg hagberg@lanl.gov Dan Schult dschult@colgate.edu Pieter Swart swart@lanl.gov All rights reserved. BSD license.
- wattsStrogatzGraph :: GenIO -> Int -> Int -> Double -> IO GraphInfo
- wattsStrogatzGraph' :: Int -> Int -> Double -> IO GraphInfo
- wattsStrogatzContext :: GenIO -> Int -> [Int] -> Double -> IO GraphContext
- selectWithProbability :: GenIO -> Double -> [a] -> IO [a]
Graph generators
:: GenIO | The random number generator to use |
-> Int | n, The number of nodes |
-> Int | k, the size of the neighborhood / degree (should be even) |
-> Double | beta, The probability of a forward edge getting rewritten |
-> IO GraphInfo | The resulting graph (IO required for randomness) |
Generate a unlabelled undirected random graph using the Algorithm introduced by WattsStrogatz.
Note that self-loops with also be generated with probability p.
This algorithm runs in O(kn).
The generated nodes are identified by [0..n-1].
Example usage, using a truly random generator:
import System.Random.MWC gen <- withSystemRandom . asGenIO $ return wattsStrogatzGraph gen 1000 10 0.6
...
:: Int | n, The number of nodes |
-> Int | k, the size of the neighborhood / degree (should be even) |
-> Double | beta, The probability of a forward edge getting rewritten |
-> IO GraphInfo | The resulting graph (IO required for randomness) |
Like wattsStrogatzGraph
, but uses a newly initialized random number generator.
See withSystemRandom
for details on how the generator is
initialized.
By using this function, you don't have to initialize the generator by yourself, however generator initialization is slow, so reusing the generator is recommended.
Usage example:
wattsStrogatzGraph' 1000 10 0.6
Graph component generators
:: GenIO | The random number generator to use |
-> Int | Identifier of the context's central node |
-> [Int] | The algorithm will generate random edges to those nodes from or to the given node |
-> Double | The probability for any pair of nodes to be connected |
-> IO GraphContext | The resulting graph (IO required for randomness) |
Generate a small-world context using the Wattz Strogatz method.
See wattsStrogatzGraph
for a detailed algorithm description.
Example usage, using a truly random generator:
import System.Random.MWC gen <- withSystemRandom . asGenIO $ return