Re: [Haskell-cafe] Is the following implemented by a sparse matrix representation? type Graph n w = Array (n, n) (Maybe w)

2013-07-10 Thread Thomas Horstmeyer
Looks like the graph is represented by an adjacency matrix, where the element at (a, b) tells you whether there is an edge from node a to node b with weight x or not by having the value (Just x) or Nothing, respectively. Whether the matrix is sparse depends on the data, i.e. how many edges are

Re: [Haskell-cafe] Is the following implemented by a sparse matrix representation? type Graph n w = Array (n, n) (Maybe w)

2013-07-10 Thread Twan van Laarhoven
The standard array types, such as Array (n,n) (Maybe w) will be implemented as a dense array. If you want to use a sparse matrix, you will explicitly have to ask for it. For instance by using something like IntMap (IntMap w) or Map (n,n) w or Array n (IntMap w). Each of these representations is

Re: [Haskell-cafe] Is the following implemented by a sparse matrix representation? type Graph n w = Array (n, n) (Maybe w)

2013-07-10 Thread KC
Thank you :) On Wed, Jul 10, 2013 at 8:33 AM, Twan van Laarhoven twa...@gmail.comwrote: The standard array types, such as Array (n,n) (Maybe w) will be implemented as a dense array. If you want to use a sparse matrix, you will explicitly have to ask for it. For instance by using something