Class GraphHuffman

    • Constructor Detail

      • GraphHuffman

        public GraphHuffman​(int nVertices)
        Parameters:
        nVertices - number of vertices in the graph that this Huffman tree is being built for
      • GraphHuffman

        public GraphHuffman​(int nVertices,
                            int maxCodeLength)
        Parameters:
        nVertices - nVertices number of vertices in the graph that this Huffman tree is being built for
        maxCodeLength - MAX_CODE_LENGTH for Huffman tree
    • Method Detail

      • buildTree

        public void buildTree​(int[] vertexDegree)
        Build the Huffman tree given an array of vertex degrees
        Parameters:
        vertexDegree - vertexDegree[i] = degree of ith vertex
      • getCode

        public long getCode​(int vertexNum)
        Specified by:
        getCode in interface BinaryTree
      • getCodeLength

        public int getCodeLength​(int vertexNum)
        Specified by:
        getCodeLength in interface BinaryTree