示例#1
0
  /**
   * the level for the given network
   *
   * @param network
   * @return
   */
  public static int computeLevel(GraphModel network) {
    // first mark reticulation vertices
    // boolean isRetic[] = new boolean[network.getVerticesCount()];
    for (VertexModel v : network) {
      if (network.getOutDegree(v) == 1 && network.getInDegree(v) == 2)
        v.setUserDefinedAttribute("retic", true);
      // isRetic[v.getId()] = true;
    }

    // then make an undirected copy
    GraphModel U = createUndirectedCopy(network);
    BiconnectedComponents bc = new BiconnectedComponents();
    Vector<HashSet<VertexModel>> comps =
        bc.biconnected_components(U, U.getAVertex(), U.getVerticesCount());
    int maxk = 0;
    for (HashSet<VertexModel> component : comps) {
      int k = 0;
      for (VertexModel scan : component)
        if (scan.getUserDefinedAttribute("retic") != null)
          // isRetic[((VertexModel) (scan.getProp().obj)).getId()])
          k++;
      maxk = Math.max(maxk, k);
    }
    return maxk;
  }