class_docstr: Forest structure, i.e. a set of trees
  
  The nodes can be segmented into trees.
  
  Within each tree a node has one parent and children
  that describe the associated hierarchical structure.
  Some of the nodes can be viewed as leaves, other as roots
  The edges within a tree are associated with a weight:
  
  * +1 from child to parent
  * -1 from parent to child
  
  Attributes
  ----------
  V : int
      int > 0, the number of vertices
  E : int
      the number of edges
  parents : (self.V,) array
      the parent array
  edges : (self.E, 2) array
      representing pairwise neighbors
  weights : (self.E,) array
      +1/-1 for ascending/descending links
  children: list
      list of arrays that represents the children any node
class_docstr_tok: ["Forest","structure",",","i.e",".","a","set","of","trees","The","nodes","can","be","segmented","into","trees",".","Within","each","tree","a","node","has","one","parent","and","children","that","describe","the","associated","hierarchical","structure",".","Some","of","the","nodes","can","be","viewed","as","leaves",",","other","as","roots","The","edges","within","a","tree","are","associated","with","a","weight",":","*","+1","from","child","to","parent","*","-1","from","parent","to","child","Attributes","--","--","--","--","--","V",":","int","int",">","0",",","the","number","of","vertices","E",":","int","the","number","of","edges","parents",":","(","self.V",",",")","array","the","parent","array","edges",":","(","self.E",",","2",")","array","representing","pairwise","neighbors","weights",":","(","self.E",",",")","array","+1\/-1","for","ascending\/descending","links","children",":","list","list","of","arrays","that","represents","the","children","any","node"]
docstr: Creates a subforest with the vertices for which valid > 0
  
  Parameters
  ----------
  valid: array of shape (self.V): indicator of the selected nodes
  
  Returns
  -------
  subforest: a new forest instance, with a reduced set of nodes
  
  Notes
  -----
  The children of deleted vertices become their own parent
docstr_tok: ["Creates","a","subforest","with","the","vertices","for","which","valid",">","0","Parameters","--","--","--","--","--","valid",":","array","of","shape","(","self.V",")",":","indicator","of","the","selected","nodes","Returns","--","--","--","-","subforest",":","a","new","forest","instance",",","with","a","reduced","set","of","nodes","Notes","--","--","-","The","children","of","deleted","vertices","become","their","own","parent"]
code: def subforest(self, valid):
      """Creates a subforest with the vertices for which valid > 0
  
      Parameters
      ----------
      valid: array of shape (self.V): indicator of the selected nodes
  
      Returns
      -------
      subforest: a new forest instance, with a reduced set of nodes
  
      Notes
      -----
      The children of deleted vertices become their own parent
      """
      if np.size(valid) != self.V:
          raise ValueError("incompatible size for self anf valid")
  
      parents = self.parents.copy()
      j = np.nonzero(valid[self.parents] == 0)[0]
      parents[j] = j
      parents = parents[valid.astype(bool)]
      renumb = np.hstack((0, np.cumsum(valid)))
      parents = renumb[parents]
  
      F = Forest(np.sum(valid), parents)
  
      return F
  
imports: import numpy
  from .graph import WeightedGraph
label_desc: Use image node_id 9 for calling the Forest obj's underlying member method code with example usage: obj.subforest(valid) and returns: F