Example: Dendrogram

A Dendrogram.
using Imsl.Chart2D;
using Imsl.Stat;
using System;
using System.Windows.Forms;
using System.Drawing;

public class DendrogramEx1 : FrameChart
{
    public DendrogramEx1()
    {
        Chart chart = this.Chart;
        AxisXY axis = new AxisXY(chart);
        double[,] data = {{.38, 626.5, 601.3, 605.3},
                         {.18, 654.0, 647.1, 641.8},
                         {.07, 677.2, 676.5, 670.5},
                         {.09, 639.9, 640.3, 636.0},
                         {.19, 614.7, 617.3, 606.2},
                         {.12, 670.2, 666.0, 659.3},
                         {.20, 651.1, 645.2, 643.4},
                         {.41, 645.4, 645.8, 644.8},
                         {.07, 683.5, 682.9, 674.3},
                         {.39, 648.6, 647.8, 643.1},
                         {.21, 650.4, 650.8, 643.9},
                         {.24, 637.0, 636.9, 626.5},
                         {.09, 641.1, 628.8, 629.4},
                         {.12, 638.0, 627.7, 628.6},
                         {.11, 661.4, 659.0, 651.8},
                         {.22, 646.4, 646.2, 647.0},
                         {.33, 634.1, 632.0, 627.8}};

        System.String[] lab = new System.String[]{"lau", "ccu", "bhu", "ing",
         "com", "smm", "bur", "gln", "pvu", "sgu", "abc", "pas", "lan", "plm",
         "tor", "dor", "lbu"};

        Dissimilarities dist = new Dissimilarities(data, 0, 1, 1);
        double[,] distanceMatrix = dist.DistanceMatrix;
        ClusterHierarchical clink = new ClusterHierarchical(
           dist.DistanceMatrix, 4, 0);

        int nClusters = 4;
        int[] iclus = clink.GetClusterMembership(nClusters);
        int[] nclus = clink.GetObsPerCluster(nClusters);

        // use either method below to create the chart
        Dendrogram dc = new Dendrogram(axis, clink,
           Data.DENDROGRAM_TYPE_HORIZONTAL);

        dc.SetLabels(lab);
        dc.SetLineColors(new Color[] {Color.Blue, Color.Green, Color.Red,
                                        Color.Orange});
    }

    public static void Main(string[] argv)
    {
        System.Windows.Forms.Application.Run(new DendrogramEx1());
    }
}

Output

Link to C# source.