docs: def stationary_distribution(H, pi=None, P=None):
      """Computes the stationary distribution of a random walk on the given
      hypergraph using the iterative approach explained in the paper:
      Aurelien Ducournau, Alain Bretto, Random walks in directed hypergraphs and
      application to semi-supervised image segmentation,
      Computer Vision and Image Understanding, Volume 120, March 2014,
      Pages 91-102, ISSN 1077-3142, http://dx.doi.org/10.1016/j.cviu.2013.10.012.
      (http://www.sciencedirect.com/science/article/pii/S1077314213002038)
  
      :param H: the hypergraph to find the 'Stationary Distribution'
              algorithm on.
      :param pi: the initial distribution over the nodes. If not provided,
              it will be created with a random distribution.
      :param P: the transition matrix for the hypergraph. If not provided,
              it will be created.
      :returns: list -- list of the stationary probabilities for all nodes
              in the hypergraph.
      :raises: TypeError -- Algorithm only applicable to undirected hypergraphs
      :raises: AssertionError -- Each node must have at least 1 outgoing
               hyperedge (even if it's only a self-loop).
  
      """
      if not isinstance(H, DirectedHypergraph):
          raise TypeError("Algorithm only applicable to undirected hypergraphs")
  
      for node in H.node_iterator():
          if len(H.get_forward_star(node)) == 0:
              raise AssertionError("Each node must have at least 1 outgoing \
                                    hyperedge (even if it's only a self-loop).")
  
      indices_to_nodes, nodes_to_indices = \
          dmat.get_node_mapping(H)
      indices_to_hyperedge_ids, hyperedge_ids_to_indices = \
          dmat.get_hyperedge_id_mapping(H)
  
      if P is None:
          P = _compute_transition_matrix(H,
                                         nodes_to_indices,
                                         hyperedge_ids_to_indices)
  
      node_count = len(H.get_node_set())
      if pi is None:
          pi = _create_random_starter(node_count)
      pi_star = _create_random_starter(node_count)
      while not _has_converged(pi_star, pi):
          pi = pi_star
          pi_star = pi * P
  
      return pi