Exemplo n.º 1
0
 private boolean edgesCompatible(int edge1, int edge2) {
   E e1 = edgeList1.get(edge1);
   E e2 = edgeList2.get(edge2);
   boolean result = false;
   // edge label must be the same
   if (e1.getLabel().equals(e2.getLabel())) {
     // check connecting vertex labels
     L v1SourceLbl = g1.getEdgeSource(e1).getLabel(),
         v1TargetLbl = g1.getEdgeTarget(e1).getLabel(),
         v2SourceLbl = g2.getEdgeSource(e2).getLabel(),
         v2TargetLbl = g2.getEdgeTarget(e2).getLabel();
     // checks if the pair of source vertices have the same label, and checks the same for the
     // target vertices
     boolean sourceTargetMatch =
         v1SourceLbl.equals(v2SourceLbl) && v1TargetLbl.equals(v2TargetLbl);
     if (directed) {
       result = sourceTargetMatch;
     } else {
       // checks if source1,target2 have the same label and if target1,source2 have the same label
       boolean sourceTargetInverseMatch =
           v1SourceLbl.equals(v2TargetLbl) && v1TargetLbl.equals(v2SourceLbl);
       result = (sourceTargetMatch || sourceTargetInverseMatch);
     }
   }
   return result;
 }
  @Override
  protected int compareNotNullObjects(E left, E right) {
    // on trie en priorité sur la position, puis sur le libellé et enfin par l'identifiant
    int order = positionComparator.compare(left.getPosition(), right.getPosition());

    if (order == 0) {
      order = labelComparator.compare(left.getLabel(), right.getLabel());
    }

    if (order == 0) {
      order = super.compareNotNullObjects(left, right);
    }

    return order;
  }