001    // Copyright 2012, 2013 Brad Block, Pawjaw, LLC. (an Ohio Limited Liability Company)
002    // 
003    // This file is part of JBTCRF.
004    // 
005    // JBTCRF is free software: you can redistribute it and/or modify
006    // it under the terms of the GNU General Public License as published by
007    // the Free Software Foundation, either version 3 of the License, or
008    // (at your option) any later version.
009    // 
010    // JBTCRF is distributed in the hope that it will be useful,
011    // but WITHOUT ANY WARRANTY; without even the implied warranty of
012    // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
013    // GNU General Public License for more details.
014    // 
015    // You should have received a copy of the GNU General Public License
016    // along with JBTCRF.  If not, see <http://www.gnu.org/licenses/>.
017    
018    package com.pawjaw.classification.crf.lmcbt.trees;
019    
020    import java.util.List;
021    
022    public class Node {
023        public int split_feature = -1;
024        public double output;
025        public Node true_child = null;
026        public Node false_child = null;
027        public int[] example_indexes;
028    
029        public Node(List<Integer> example_indexes) {
030            this(0, example_indexes);
031        }
032    
033        public Node(int[] example_indexes) {
034            this(0, example_indexes);
035        }
036    
037        public Node(double output, List<Integer> example_indexes) {
038            int i = 0;
039            this.output = output;
040            this.example_indexes = new int[example_indexes.size()];
041            for(int example_index : example_indexes)
042                this.example_indexes[i++] = example_index;
043        }
044    
045        public Node(double output, int[] example_indexes) {
046            this.output = output;
047            this.example_indexes = example_indexes;
048        }
049    
050        public boolean isLeaf() {
051            return true_child == null || false_child == null;
052        }
053    }