public Prim() { size = 0; mstCost = 0; MST.Clear(); col_distinct = ImageOperations.distinct_colour(); size = col_distinct.Count; visited = new bool[size]; parent = new int[size]; distance = new double[size]; edge = new minHeap(); }
private void buildTree(ref minHeap temp) { node temp1, temp2, newNode; while (temp.count() > 1) { temp1 = temp.extractMin(); temp2 = temp.extractMin(); newNode = new node(0, temp1.frequency + temp2.frequency, temp2, temp1); // 2(N-1) temp.add(newNode); } }
public huffman(RGBPixel[,] arr) { redHeap = new minHeap(); blueHeap = new minHeap(); greenHeap = new minHeap(); redCode = new Dictionary <byte, string>(256); blueCode = new Dictionary <byte, string>(256); greenCode = new Dictionary <byte, string>(256); redFrequencies = new int[256]; greenFrequencies = new int[256]; blueFrequencies = new int[256]; redTree = ""; blueTree = ""; greenTree = ""; computeFrequencies(arr); }
public huffman(RGBPixel[,] arr) { Dictionary <byte, int> temp1 = new Dictionary <byte, int>(); Dictionary <byte, int> temp2 = new Dictionary <byte, int>(); Dictionary <byte, int> temp3 = new Dictionary <byte, int>(); computeFrequencies(arr, ref temp1, ref temp2, ref temp3); redFrequency = new minHeap(); blueFrequency = new minHeap(); greenFrequency = new minHeap(); foreach (var item in temp1) { node newNode = new node(item.Key, item.Value); redFrequency.add(newNode); } foreach (var item in temp2) { node newNode = new node(item.Key, item.Value); blueFrequency.add(newNode); } foreach (var item in temp3) { node newNode = new node(item.Key, item.Value); greenFrequency.add(newNode); } buildTree(ref redFrequency); buildTree(ref blueFrequency); buildTree(ref greenFrequency); redCode = new Dictionary <byte, string>(); blueCode = new Dictionary <byte, string>(); greenCode = new Dictionary <byte, string>(); getBinaryCode(redFrequency.getRoot(), "", ref redCode); getBinaryCode(blueFrequency.getRoot(), "", ref blueCode); getBinaryCode(greenFrequency.getRoot(), "", ref greenCode); }