KC | 9 Jul 23:26 2013
Picon

Is the following implemented by a sparse matrix representation? type Graph n w = Array (n, n) (Maybe w)

type Graph n w = Array (n,n) (Maybe w)

--
--
Regards,
KC
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Thomas Horstmeyer | 10 Jul 14:10 2013
Picon

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

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 in the graph.

But perhaps I misunderstood your question.

Thomas

Am 09.07.2013 23:26, schrieb KC:
> type Graph n w = Array (n,n) (Maybe w)
Twan van Laarhoven | 10 Jul 17:33 2013
Picon

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

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 slightly 
different, and there will be different trade-offs.

Twan

On 09/07/13 23:26, KC wrote:
 > Is the following implemented by a sparse matrix representation?
> type Graph n w = Array (n,n) (Maybe w)
>
> --
> --
> Regards,
> KC
KC | 10 Jul 18:27 2013
Picon

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

Thank you :)


On Wed, Jul 10, 2013 at 8:33 AM, Twan van Laarhoven <twanvl <at> gmail.com> wrote:
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 slightly different, and there will be different trade-offs.


Twan

On 09/07/13 23:26, KC wrote:
> Is the following implemented by a sparse matrix representation?

type Graph n w = Array (n,n) (Maybe w)

--
--
Regards,
KC



_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe



--
--
Regards,
KC
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Gmane