Example #1
0
 @Test
 public void fusedPentagons() {
   Graph g = new Graph("0:1,0:4,1:2,2:3,3:4,3:7,4:5,5:6,6:7");
   Block b = new Block(g);
   SpanningTree tree = new SpanningTree(b);
   System.out.println("T= " + tree.getTree());
   System.out.println("cE= " + tree.getCycleEdges());
   List<Block> basis = CycleFinder.getCycleBasis(tree);
   System.out.println("FCS= " + basis);
   int counter = 0;
   List<Block> all = new ArrayList<Block>();
   CycleFinder.expand(basis, all, b);
   for (Block cycle : all) {
     System.out.println(counter + "\t" + cycle);
     counter++;
   }
 }
Example #2
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);
  }
Example #3
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++;
    }
  }