code: public static double[] insideAlgorithm(final Hypergraph graph, final Hyperpotential w, final Semiring s) {
          final int n = graph.getNodes().size();
          final double[] beta = new double[n];
          // \beta_i = 0 \forall i
          Arrays.fill(beta, s.zero());
          graph.applyTopoSort(new HyperedgeFn() {
  
              @Override
              public void apply(Hyperedge e) {
                  // \beta_{H(e)} += w_e \prod_{j \in T(e)} \beta_j
                  double prod = s.one();
                  for (Hypernode jNode : e.getTailNodes()) {
                      prod = s.times(prod, beta[jNode.getId()]);
                  }
                  int i = e.getHeadNode().getId();
                  prod = s.times(w.getScore(e, s), prod);
                  beta[i] = s.plus(beta[i], prod);
                  //if (log.isTraceEnabled()) { log.trace(String.format("inside: %s w_e=%f prod=%f beta[%d] = %f", e.getLabel(), ((Algebra)s).toReal(w.getScore(e, s)), prod, i, ((Algebra)s).toReal(beta[i]))); }
              }
              
          });
          return beta;
      }
docs: Runs the inside algorithm on a hypergraph.
  
  @param graph The hypergraph.
  @return The beta value for each Hypernode. Where beta[i] is the inside
  score for the i'th node in the Hypergraph, graph.getNodes().get(i).