title: Java tree classes
body: <p>I'm trying to make my own tree class but keep getting horribly confused. Basically I'm trying to make a weighted tree. I've made the following node class: </p>
  
  <pre><code> import java.util.*;
  
  public class subdivNode {
  
  private int nodevalue;
  private int nodeID;
  private List&lt;subdivNode&gt; childnodes; 
  
  public subdivNode(int value, int id){
      nodevalue = value;
      nodeID = id;
  }
  
  public int getValue(){
      return nodevalue;
  }
  
  public int getId(){
      return nodeID;
  }
  
  public void addChild(subdivNode child){
      childnodes.add(child);
  }
  
  public int getNumChildren(){
      return childnodes.size();
  }
  
  public subdivNode getChild(int pos){    //return's i'th child
      return childnodes.get(pos);
  }
  }
  </code></pre>
  
  <p>And this is the skeleton for my tree class so far:</p>
  
  <pre><code>public class subdivTree {
  
  private subdivNode rootnode;
  
  public subdivTree(){
      rootnode = new subdivNode(0,0);
  }
  
  public void addNode(int parent, int value){
  
  }
  
  public int getNodeValue(int node){
  
      return 0;
  }
  
  public int getNumChildren(int node){
      return 0;
  }
  
  
  }
  </code></pre>
  
  <p>Beyond that I have no idea</p>
  
  <p>EDIT: Sorry for the ambiguity. My question should have been how would I go about implementing the addnode method in subdivTree. The end goal is to create an alogrithim which searches the tree for the path between any two nodes such that the greatest value(adding the value of all the in between nodes) is obtained.</p>