node.java

来自「java算法大全」· Java 代码 · 共 84 行

JAVA
84
字号
class Node {    String label;    int weight;    Node leftNode, rightNode;    int x, y;    int depth = -1;    boolean highlightLeft = false, highlightRight = false, highlight = false;        public Node(Node node1, Node node2) {	leftNode = node1;	rightNode = node2;	weight = node1.getWeight() + node2.getWeight();	label = new String();    }    public Node(Node node) {	leftNode = node;	rightNode = null;	weight = 0;	label = new String();    }    public Node() {	label = new String();	weight = 0;	leftNode = rightNode = null;    } // Constructor 1        public Node(String label, int weight) {	this.label = new String(label);	this.weight = weight;	leftNode = rightNode = null;    } // Constructor 2        public Node(int weight) {	this.label = new String();	this.weight = weight;	leftNode = rightNode = null;    } // Constructor 3        public Node(String label) {	this.label = new String(label);	this.weight = 0;	leftNode = rightNode = null;    } // Constructor 4        public void setWeight(int weight) {	this.weight = weight;    }        public void setLabel(String label) {	this.label = new String(label);    }        public int getWeight() {	return weight;    }        public String getLabel() {	return new String(label);    }    public void setLeftNode(Node node) {	leftNode = node;    }    public void setRightNode(Node node) {	rightNode = node;    }    public Node getLeftNode() {	return leftNode;    }    public Node getRightNode() {	return rightNode;    }    public boolean isLeaf() {	return ((rightNode==null)&&(leftNode==null));    }} // class Node

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?