コード例 #1
0
  public void find(Block b) {
    SpanningTree tree = new SpanningTree(b);
    List<Block> basis = CycleFinder.getCycleBasis(tree);
    int basisCounter = 0;
    for (Block cycle : basis) {
      System.out.println(basisCounter + "\t" + cycle);
      basisCounter++;
    }

    List<Block> all = new ArrayList<Block>();
    CycleFinder.expand(basis, all, b);
    int fullCounter = 0;
    for (Block cycle : all) {
      System.out.println(fullCounter + "\t" + cycle.esize() + "\t" + cycle);
      fullCounter++;
    }

    // this assertion fails for disconnected graphs - does the CC number count in the formula?
    Assert.assertEquals((b.esize() - b.vsize() + 1), basisCounter);

    Assert.assertEquals((int) Math.pow(2, basisCounter), fullCounter);
  }
コード例 #2
0
  public void debugFind(Block b) {
    SpanningTree tree = new SpanningTree(b);
    List<Block> basis = CycleFinder.getCycleBasis(tree);
    List<BitSet> baseSets = new ArrayList<BitSet>();

    int basisCounter = 0;
    for (Block cycle : basis) {
      baseSets.add(CycleFinder.cycleToBitSet(cycle, b));
      System.out.println(basisCounter + "\t" + cycle);
      basisCounter++;
    }

    SubsetLister<BitSet> subsetLister = new SubsetLister<BitSet>(baseSets);

    int fullCounter = 0;
    for (List<BitSet> subSet : subsetLister) {
      if (!viable(subSet)) continue;
      BitSet bS = CycleFinder.combine(subSet);
      Block cycle = CycleFinder.toCycle(bS, b);
      System.out.println(fullCounter + "\t" + cycle.esize() + "\t" + cycle + "\t" + subSet);
      fullCounter++;
    }
  }