@@ -185,20 +185,21 @@ private void addChildToQueue(int fixedEditorialCost,
185185 List <Vertex > allTargets
186186 ) {
187187 Mapping parentPartialMapping = parentEntry .partialMapping ;
188- int level = parentEntry .level ;
188+ int parentLevel = parentEntry .level ;
189+ int level = parentLevel + 1 ;
189190
190- assertTrue (level == parentPartialMapping .size ());
191+ assertTrue (parentLevel == parentPartialMapping .size ());
191192
192193 // the available target vertices are the parent queue entry ones plus
193194 // minus the additional mapped element in parentPartialMapping
194195 ArrayList <Vertex > availableTargetVertices = new ArrayList <>(parentEntry .availableTargetVertices );
195- availableTargetVertices .remove (parentPartialMapping .getTarget (level - 1 ));
196+ availableTargetVertices .remove (parentPartialMapping .getTarget (parentLevel - 1 ));
196197 assertTrue (availableTargetVertices .size () + parentPartialMapping .size () == allTargets .size ());
197- Vertex v_i = allSources .get (level );
198+ Vertex v_i = allSources .get (parentLevel );
198199
199200
200201 // the cost matrix is for the non mapped vertices
201- int costMatrixSize = allSources .size () - level ;
202+ int costMatrixSize = allSources .size () - parentLevel ;
202203
203204 // costMatrix gets modified by the hungarian algorithm ... therefore we create two of them
204205 double [][] costMatrixForHungarianAlgo = new double [costMatrixSize ][costMatrixSize ];
@@ -207,13 +208,13 @@ private void addChildToQueue(int fixedEditorialCost,
207208
208209 Map <Vertex , Double > isolatedVerticesCache = new LinkedHashMap <>();
209210
210- for (int i = level ; i < allSources .size (); i ++) {
211+ for (int i = parentLevel ; i < allSources .size (); i ++) {
211212 Vertex v = allSources .get (i );
212213 int j = 0 ;
213214 for (Vertex u : availableTargetVertices ) {
214215 double cost = calcLowerBoundMappingCost (v , u , parentPartialMapping , isolatedVerticesCache );
215- costMatrixForHungarianAlgo [i - level ][j ] = cost ;
216- costMatrix [i - level ][j ] = cost ;
216+ costMatrixForHungarianAlgo [i - parentLevel ][j ] = cost ;
217+ costMatrix [i - parentLevel ][j ] = cost ;
217218 j ++;
218219 }
219220 runningCheck .check ();
@@ -223,24 +224,29 @@ private void addChildToQueue(int fixedEditorialCost,
223224 int editorialCostForMapping = editorialCostForMapping (fixedEditorialCost , parentPartialMapping , completeSourceGraph , completeTargetGraph );
224225 double costMatrixSum = getCostMatrixSum (costMatrix , assignments );
225226 double lowerBoundForPartialMapping = editorialCostForMapping + costMatrixSum ;
226- int v_i_target_IndexSibling = assignments [0 ];
227- Vertex bestExtensionTargetVertexSibling = availableTargetVertices .get (v_i_target_IndexSibling );
228- Mapping newMappingSibling = parentPartialMapping .extendMapping (v_i , bestExtensionTargetVertexSibling );
227+
228+ Mapping newMapping = parentPartialMapping .extendMapping (v_i , availableTargetVertices .get (assignments [0 ]));
229229
230230
231231 if (lowerBoundForPartialMapping >= optimalEdit .ged ) {
232232 return ;
233233 }
234- MappingEntry newMappingEntry = new MappingEntry (newMappingSibling , level + 1 , lowerBoundForPartialMapping );
234+ MappingEntry newMappingEntry = new MappingEntry (newMapping , level , lowerBoundForPartialMapping );
235235 LinkedBlockingQueue <MappingEntry > siblings = new LinkedBlockingQueue <>();
236236 newMappingEntry .mappingEntriesSiblings = siblings ;
237237 newMappingEntry .assignments = assignments ;
238238 newMappingEntry .availableTargetVertices = availableTargetVertices ;
239239
240240 queue .add (newMappingEntry );
241+
242+ /**
243+ * Extend the partial mapping to a full mapping according to the optimal
244+ * matching (hungarian algo result) and update the optimal edit if we
245+ * found a better one.
246+ */
241247 Mapping fullMapping = parentPartialMapping .copy ();
242248 for (int i = 0 ; i < assignments .length ; i ++) {
243- fullMapping .add (allSources .get (level + i ), availableTargetVertices .get (assignments [i ]));
249+ fullMapping .add (allSources .get (parentLevel + i ), availableTargetVertices .get (assignments [i ]));
244250 }
245251
246252 int costForFullMapping = editorialCostForMapping (fixedEditorialCost , fullMapping , completeSourceGraph , completeTargetGraph );
@@ -257,7 +263,7 @@ private void addChildToQueue(int fixedEditorialCost,
257263 parentPartialMapping ,
258264 v_i ,
259265 optimalEdit .ged ,
260- level + 1 ,
266+ level ,
261267 siblings
262268 );
263269 }
@@ -288,9 +294,7 @@ private void calculateRestOfChildren(List<Vertex> availableTargetVertices,
288294
289295 double costMatrixSumSibling = getCostMatrixSum (costMatrixCopy , assignments );
290296 double lowerBoundForPartialMappingSibling = editorialCostForMapping + costMatrixSumSibling ;
291- int v_i_target_IndexSibling = assignments [0 ];
292- Vertex bestExtensionTargetVertexSibling = availableTargetVertices .get (v_i_target_IndexSibling );
293- Mapping newMappingSibling = partialMapping .extendMapping (v_i , bestExtensionTargetVertexSibling );
297+ Mapping newMappingSibling = partialMapping .extendMapping (v_i , availableTargetVertices .get (assignments [0 ]));
294298
295299
296300 if (lowerBoundForPartialMappingSibling >= upperBound ) {
0 commit comments