// yields the children-to-parent relations from R
  public static String[] getRelationsFromR(String R, String a1_to_B, String a2_to_B) {
    Set<String> possiblePatterns = new HashSet<String>(25, 1.0f);
    Set<String> consistentPatterns = new HashSet<String>(25, 1.0f);
    String[] newRelations = new String[2];

    for (char relation : R.toCharArray())
      possiblePatterns.addAll(FROM_R_TO_RELATIONS.get("" + relation));

    boolean matchesPattern;
    for (String pattern : possiblePatterns) {
      matchesPattern =
          a1_to_B.contains("" + pattern.charAt(0)) && a2_to_B.contains("" + pattern.charAt(1));
      if (matchesPattern) consistentPatterns.add(pattern);
    }

    String new_a1_to_B = "";
    String new_a2_to_B = "";
    for (String pattern : consistentPatterns) {
      new_a1_to_B += Articulations.union(new_a1_to_B, "" + pattern.charAt(0));
      new_a2_to_B += Articulations.union(new_a2_to_B, "" + pattern.charAt(1));
    }

    newRelations[0] = new_a1_to_B;
    newRelations[1] = new_a2_to_B;

    return newRelations;
  }
 // yields R from the children-to-parent relations
 public static String getRFromRelations(String a1_to_B, String a2_to_B) {
   String R = "";
   for (char r1 : a1_to_B.toCharArray())
     for (char r2 : a2_to_B.toCharArray())
       R = Articulations.union(R, FROM_RELATIONS_TO_R.get("" + r1 + r2));
   return R;
 }