public class GraphHuffman extends java.lang.Object implements BinaryTree
Constructor and Description |
---|
GraphHuffman(int nVertices) |
GraphHuffman(int nVertices,
int maxCodeLength) |
Modifier and Type | Method and Description |
---|---|
void |
buildTree(int[] vertexDegree)
Build the Huffman tree given an array of vertex degrees
|
long |
getCode(int vertexNum) |
int |
getCodeLength(int vertexNum) |
java.lang.String |
getCodeString(int vertexNum) |
int[] |
getPathInnerNodes(int vertexNum) |
public GraphHuffman(int nVertices)
nVertices
- number of vertices in the graph that this Huffman tree is being built forpublic GraphHuffman(int nVertices, int maxCodeLength)
nVertices
- nVertices number of vertices in the graph that this Huffman tree is being built formaxCodeLength
- MAX_CODE_LENGTH for Huffman treepublic void buildTree(int[] vertexDegree)
vertexDegree
- vertexDegree[i] = degree of ith vertexpublic long getCode(int vertexNum)
getCode
in interface BinaryTree
public int getCodeLength(int vertexNum)
getCodeLength
in interface BinaryTree
public java.lang.String getCodeString(int vertexNum)
getCodeString
in interface BinaryTree
public int[] getPathInnerNodes(int vertexNum)
getPathInnerNodes
in interface BinaryTree