View Javadoc
1   /*
2    * Created on Feb 3, 2007
3    *
4    * Copyright (c) 2007, The JUNG Authors 
5    *
6    * All rights reserved.
7    *
8    * This software is open-source under the BSD license; see either
9    * "license.txt" or
10   * https://github.com/jrtom/jung/blob/master/LICENSE for a description.
11   */
12  package edu.uci.ics.jung.graph;
13  
14  
15  /**
16   * A subtype of <code>Graph</code> which is a (directed, rooted) tree.
17   * What we refer to as a "tree" here is actually (in the terminology of graph theory) a
18   * rooted tree.  (That is, there is a designated single vertex--the <i>root</i>--from which we measure
19   * the shortest path to each vertex, which we call its <i>depth</i>; the maximum over all such 
20   * depths is the tree's <i>height</i>.  Note that for a tree, there is exactly
21   * one unique path from the root to any vertex.)
22   * 
23   * @author Joshua O'Madadhain
24   */
25  public interface Tree<V,E> extends Forest<V,E>
26  {
27      /**
28       * Returns the (unweighted) distance of <code>vertex</code> 
29       * from the root of this tree.
30       * @param vertex    the vertex whose depth is to be returned.
31       * @return the length of the shortest unweighted path 
32       * from <code>vertex</code> to the root of this tree
33       * @see #getHeight()
34       */
35      public int getDepth(V vertex);
36      
37      /**
38       * Returns the maximum depth in this tree.
39       * @return the maximum depth in this tree
40       * @see #getDepth(Object)
41       */
42      public int getHeight();
43      
44      /**
45       * Returns the root of this tree.
46       * The root is defined to be the vertex (designated either at the tree's
47       * creation time, or as the first vertex to be added) with respect to which 
48       * vertex depth is measured.
49       * @return the root of this tree
50       */
51      public V getRoot();
52  }