Menu

getChildCount return value

Adam
2012-04-09
2013-05-29
  • Adam

    Adam - 2012-04-09

    What returns the method getChildCount  of DelegateTree class? It is a bit unclear for me (after reading API doc) if it's the number of immediate children or the number of all descendants.

     
  • Joshua O'Madadhain

    Adam:

    "Successor" is not the same thing as "descendant".  In mathematical contexts such as this, "successor of X" is something that comes right after X, not something that appears at some point later.

    In any case, it's the number of immediate children, which is why it's called "getChildCount". 

    Joshua

     
  • Adam

    Adam - 2012-04-09

    Thank you for the explicit answer.
    So I lack the method returning  the number of all descendants of given v ( =  -1 ). Surely, it may be calculated quite easily (e.g. by BFS), anyway I thought there is some method doing this.

     
  • Joshua O'Madadhain

    If you don't mind some overhead, you can use TreeUtils.getSubtree().getVertexCount() - 1.  Or you can write a few lines of code.

    Joshua

     

Log in to post a comment.