@@ -640,6 +640,7 @@ private boolean isMappingPossible(Vertex v,
640640 Map <String , Set <Vertex >> isolatedTargetVertices = isolatedInfo .isolatedTargetVertices ;
641641 Set <Vertex > isolatedBuiltInSourceVertices = isolatedInfo .isolatedBuiltInSourceVertices ;
642642 Set <Vertex > isolatedBuiltInTargetVertices = isolatedInfo .isolatedBuiltInTargetVertices ;
643+
643644 if (v .isArtificialNode ()) {
644645 if (u .isBuiltInType ()) {
645646 return isolatedBuiltInSourceVertices .contains (v );
@@ -658,17 +659,32 @@ private boolean isMappingPossible(Vertex v,
658659 if (!v .getType ().equals (u .getType ())) {
659660 return false ;
660661 }
661- if (isNamedType (v .getType ())) {
662- Vertex targetVertex = targetGraph .getType (v .get ("name" ));
663- if (targetVertex != null && Objects .equals (v .getType (), targetVertex .getType ())) {
664- forcedMatchingCache .put (v , targetVertex );
665- return u == targetVertex ;
666- }
662+ Boolean result = checkNamedTypes (v , u , targetGraph );
663+ if (result != null ) {
664+ return result ;
667665 }
666+ result = checkNamedTypes (u , v , sourceGraph );
667+ if (result != null ) {
668+ return result ;
669+ }
670+ result = checkSpecificTypes (v , u , sourceGraph , targetGraph );
671+ if (result != null ) {
672+ return result ;
673+ }
674+ result = checkSpecificTypes (u , v , targetGraph , sourceGraph );
675+ if (result != null ) {
676+ return result ;
677+ }
678+
679+ return true ;
680+ }
681+
682+ private Boolean checkSpecificTypes (Vertex v , Vertex u , SchemaGraph sourceGraph , SchemaGraph targetGraph ) {
668683 if (DIRECTIVE .equals (v .getType ())) {
669684 Vertex targetVertex = targetGraph .getDirective (v .get ("name" ));
670685 if (targetVertex != null ) {
671686 forcedMatchingCache .put (v , targetVertex );
687+ forcedMatchingCache .put (targetVertex , v );
672688 return u == targetVertex ;
673689 }
674690 }
@@ -681,13 +697,15 @@ private boolean isMappingPossible(Vertex v,
681697 if (matchingTargetField != null ) {
682698 Vertex dummyTypeVertex = getDummyTypeVertex (matchingTargetField , targetGraph );
683699 forcedMatchingCache .put (v , dummyTypeVertex );
700+ forcedMatchingCache .put (dummyTypeVertex , v );
684701 return u == dummyTypeVertex ;
685702 }
686703 } else if (vertex .getType ().equals (INPUT_FIELD )) {
687704 Vertex matchingTargetInputField = findMatchingTargetInputField (vertex , sourceGraph , targetGraph );
688705 if (matchingTargetInputField != null ) {
689706 Vertex dummyTypeVertex = getDummyTypeVertex (matchingTargetInputField , targetGraph );
690707 forcedMatchingCache .put (v , dummyTypeVertex );
708+ forcedMatchingCache .put (dummyTypeVertex , v );
691709 return u == dummyTypeVertex ;
692710 }
693711 }
@@ -697,26 +715,39 @@ private boolean isMappingPossible(Vertex v,
697715 Vertex matchingTargetInputField = findMatchingTargetInputField (v , sourceGraph , targetGraph );
698716 if (matchingTargetInputField != null ) {
699717 forcedMatchingCache .put (v , matchingTargetInputField );
718+ forcedMatchingCache .put (matchingTargetInputField , v );
700719 return u == matchingTargetInputField ;
701720 }
702721 }
703722 if (FIELD .equals (v .getType ())) {
704723 Vertex matchingTargetField = findMatchingTargetField (v , sourceGraph , targetGraph );
705724 if (matchingTargetField != null ) {
706725 forcedMatchingCache .put (v , matchingTargetField );
726+ forcedMatchingCache .put (matchingTargetField , v );
707727 return u == matchingTargetField ;
708728 }
709729 }
710730 if (ENUM_VALUE .equals (v .getType ())) {
711731 Vertex matchingTargetEnumValue = findMatchingEnumValue (v , sourceGraph , targetGraph );
712732 if (matchingTargetEnumValue != null ) {
713733 forcedMatchingCache .put (v , matchingTargetEnumValue );
734+ forcedMatchingCache .put (matchingTargetEnumValue , v );
714735 return u == matchingTargetEnumValue ;
715736 }
716737 }
738+ return null ;
739+ }
717740
718- // if it is named type we check if the targetGraph has one with the same name and type force a match
719- return true ;
741+ private Boolean checkNamedTypes (Vertex v , Vertex u , SchemaGraph targetGraph ) {
742+ if (isNamedType (v .getType ())) {
743+ Vertex targetVertex = targetGraph .getType (v .get ("name" ));
744+ if (targetVertex != null && Objects .equals (v .getType (), targetVertex .getType ())) {
745+ forcedMatchingCache .put (v , targetVertex );
746+ forcedMatchingCache .put (targetVertex , v );
747+ return u == targetVertex ;
748+ }
749+ }
750+ return null ;
720751 }
721752
722753 private Vertex getDummyTypeVertex (Vertex vertex , SchemaGraph schemaGraph ) {
@@ -811,13 +842,10 @@ private double calcLowerBoundMappingCost(Vertex v,
811842 if (!isMappingPossible (v , u , sourceGraph , targetGraph , partialMappingTargetSet , isolatedInfo )) {
812843 return Integer .MAX_VALUE ;
813844 }
814- // if (!isMappingPossible(u, v, targetGraph, sourceGraph, partialMappingSourceSet)) {
815- // return Integer.MAX_VALUE;
816- // }
817845 boolean equalNodes = v .getType ().equals (u .getType ()) && v .getProperties ().equals (u .getProperties ());
846+
818847 // inner edge labels of u (resp. v) in regards to the partial mapping: all labels of edges
819848 // which are adjacent of u (resp. v) which are inner edges
820-
821849 List <Edge > adjacentEdgesV = sourceGraph .getAdjacentEdges (v );
822850 Multiset <String > multisetLabelsV = HashMultiset .create ();
823851
0 commit comments