Re: [Haskell-cafe] FGL/Haskell and Hierarchical Clustering/dendograms

2009-12-28 Thread Nikolas Borrel-Jensen
Thank you very much for your reply! I have been looking at the code, and there are two problems, as I can see. First, trying with the example t1 :: Tree (Id, Cost) t1 = Node (4,0) [Node (3,2) [Node (1,12) []] ,Node (2,3) [Node (5,1) [Node (6,2) [Node (7,2) [] printed as (4,0) |

[Haskell-cafe] FGL/Haskell and Hierarchical Clustering/dendograms

2009-12-23 Thread Nikolas Borrel-Jensen
Hi! I have some trouble implementing single-linkage clustering algorithm by using a minimum-spanning tree, so I would appreciate if some of you could give me some advise. I am implementing a single-linkage clustering algorithm, and my approach is to use minimum spanning trees for that task. I am

Re: [Haskell-cafe] FGL/Haskell and Hierarchical Clustering/dendograms

2009-12-23 Thread Ketil Malde
Nikolas Borrel-Jensen nikolasbor...@gmail.com writes: I have very hard to see, how this could be done efficiently without pointers (as in C). I have thought of just saving the nodes from the start of the root path, and traversing it, but a lot of searching should be done all the time. I must

Re: [Haskell-cafe] FGL/Haskell and Hierarchical Clustering/dendograms

2009-12-23 Thread Matt Morrow
Hi Nikolas, Interesting problem. I'd do something like the following, where the initial spanning tree from you example (re-tree-ified) is: {- ghci :t t t :: Tree (Id, Cost) g ghci ppT t (4,0) | +- (3,1) | | | `- (1,1) | `- (2,3) | `- (5,12) -} and which results in the tree: {- ghci let

Re: [Haskell-cafe] FGL/Haskell and Hierarchical Clustering/dendograms

2009-12-23 Thread Matt Morrow
For completeness, you might then do the actual clustering something like: import Data.Tree import Data.List import Data.Function -- ... code from before ... cluster :: Ord cost = (a - b) - (a - cost)