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: Constructor
  
  Parameters
  ----------
  V : int
      the number of edges of the graph
  parents : None or (V,) array
      the parents of zach vertex.  If `parents`==None , the parents are
      set to range(V), i.e. each node is its own parent, and each node is
      a tree
docstr_tok: ["Constructor","Parameters","--","--","--","--","--","V",":","int","the","number","of","edges","of","the","graph","parents",":","None","or","(","V",",",")","array","the","parents","of","zach","vertex",".","If","`","parents","`","==None",",","the","parents","are","set","to","range","(","V",")",",","i.e",".","each","node","is","its","own","parent",",","and","each","node","is","a","tree"]
code: def __init__(self, V, parents=None):
      """Constructor
  
      Parameters
      ----------
      V : int
          the number of edges of the graph
      parents : None or (V,) array
          the parents of zach vertex.  If `parents`==None , the parents are
          set to range(V), i.e. each node is its own parent, and each node is
          a tree
      """
      V = int(V)
      if V < 1:
          raise ValueError("cannot create graphs with no vertex")
      self.V = int(V)
  
      # define the parents
      if parents is None:
          self.parents = np.arange(self.V).astype(np.int_)
      else:
          if np.size(parents) != V:
              raise ValueError("Incorrect size for parents")
          if parents.max() > self.V:
              raise ValueError("Incorrect value for parents")
  
          self.parents = np.reshape(parents, self.V).astype(np.int_)
  
      self.define_graph_attributes()
  
      if self.check() == 0:
          raise ValueError("The proposed structure is not a forest")
      self.children = []
  
imports: import numpy
  from .graph import WeightedGraph
label_desc: Use image node_id 1 to create a new Forest object from inherited base classes: WeightedGraph with example: obj = Forest(V, parents)