Esempio n. 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;
  }
Esempio n. 2
0
 public static GraphModel getACopy(GraphModel g) {
   GraphModel ret = new GraphModel(g.isDirected());
   VertexModel[] map = new VertexModel[g.getVerticesCount()];
   for (VertexModel v : g) {
     VertexModel t = new VertexModel(v);
     map[v.getId()] = t;
     ret.insertVertex(t);
   }
   for (EdgeModel e : g.edges()) {
     EdgeModel t = new EdgeModel(e, map[e.source.getId()], map[e.target.getId()]);
     ret.insertEdge(t);
     setDup(e, t);
   }
   return ret;
 }