Package bgu.bio.algorithms.graphs.hsa.matchers

Examples of bgu.bio.algorithms.graphs.hsa.matchers.OrderedBipartiteCavityMatcher


    // A,u,v,B,_,C,w,D,p
    // A,_,_,B,x,C,y,D,_

    int sizeX = 8;
    int sizeY = 6;
    BipartiteCavityMatcher matcher = new OrderedBipartiteCavityMatcher(
        sizeX, sizeY);

    for (int y = 0; y < sizeY; ++y) {
      matcher.setDelCostY(y, 2);
    }

    for (int x = 0; x < sizeX; ++x) {
      matcher.setDelCostX(x, 2);
      for (int y = 0; y < sizeY; ++y) {
        matcher.setMatchCost(x, y, 5);
      }
    }

    matcher.setMatchCost(0, 4, -1);
    matcher.setMatchCost(3, 5, -1);
    matcher.setMatchCost(4, 1, -1);
    matcher.setMatchCost(6, 3, -1);

    matcher.setMatchCost(5, 2, 3);

    boolean res = matcher.minCostCavityMatching(7, 5) == 13;
    System.out.println("Cavity matching test: " + res);

    res = matcher.minCostMatching() == 7;
    System.out.println("Full matching test: " + res);
    TIntArrayList[] matching = matcher.getCurrMatching();

    System.out.println("Current matching:");
    for (int i = 0; i < matching[0].size(); ++i) {
      System.out.print("(" + matching[0].get(i) + ","
          + matching[1].get(i) + "), ");
View Full Code Here


    // A,u,v,B,_,C,w,D,p
    // A,_,_,B,x,C,y,D,_

    int sizeX = 8;
    int sizeY = 6;
    BipartiteCavityMatcher matcher = new OrderedBipartiteCavityMatcher(
        sizeX, sizeY);

    for (int y = 0; y < sizeY; ++y) {
      matcher.setDelCostY(y, 2);
    }

    for (int x = 0; x < sizeX; ++x) {
      matcher.setDelCostX(x, 2);
      for (int y = 0; y < sizeY; ++y) {
        matcher.setMatchCost(x, y, 5);
      }
    }

    matcher.setMatchCost(0, 4, -1);
    matcher.setMatchCost(3, 5, -1);
    matcher.setMatchCost(4, 1, -1);
    matcher.setMatchCost(6, 3, -1);

    matcher.setMatchCost(5, 2, 3);

    Assert.assertEquals("Cavity matching answer is wrong", 13,
        matcher.minCostCavityMatching(7, 5), 0.001);

    TIntArrayList[] matching = matcher.getCavityMatching(7, 5);
    IntPairComparator comp = new IntPairComparator();

    ArrayList<IntPair> ans = new ArrayList<IntPair>();
    ArrayList<IntPair> exp = new ArrayList<IntPair>();

    ans.add(new IntPair(6, 3));
    ans.add(new IntPair(5, 2));
    ans.add(new IntPair(4, 1));
    for (int i = 0; i < matching[0].size(); ++i) {
      exp.add(new IntPair(matching[0].get(i), matching[1].get(i)));
    }

    Collections.sort(ans, comp);
    Collections.sort(exp, comp);

    isSame(ans, exp);

    Assert.assertEquals("Minimum matching answer is wrong", 7,
        matcher.minCostMatching(), 0.001);

    ans = new ArrayList<IntPair>();
    exp = new ArrayList<IntPair>();

    matching = matcher.getCurrMatching();

    ans.add(new IntPair(3, 5));
    ans.add(new IntPair(0, 4));
    ans.add(new IntPair(6, 3));
    ans.add(new IntPair(5, 2));
View Full Code Here

TOP

Related Classes of bgu.bio.algorithms.graphs.hsa.matchers.OrderedBipartiteCavityMatcher

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.