@@ -123,6 +123,16 @@ public CodebaseGraphDTO getCodebaseGraphDTO(
123123 return getCodebaseGraphDTO (repositoryPath , repositoryRoot , config );
124124 }
125125
126+ /**
127+ * Combines Java and Kotlin graphs, source mappings, and disharmonies.
128+ *
129+ * <p>Shared edge weights are summed before unattributed vertices are reconciled,
130+ * locations are hydrated, and package-to-class relationships are rebuilt.
131+ *
132+ * @param javaDto the Java analysis result
133+ * @param kotlinDto the Kotlin analysis result
134+ * @return the unified codebase graph
135+ */
126136 static CodebaseGraphDTO merge (CodebaseGraphDTO javaDto , CodebaseGraphDTO kotlinDto ) {
127137 Graph <VertexInfo , DefaultWeightedEdge > mergedClassGraph =
128138 new DefaultDirectedWeightedGraph <>(DefaultWeightedEdge .class );
@@ -312,6 +322,10 @@ private static String simpleName(String fqn) {
312322 return lastDot >= 0 ? fqn .substring (lastDot + 1 ) : fqn ;
313323 }
314324
325+ /**
326+ * Redirects a fabricated vertex's edges to its canonical declaration, summing duplicate weights.
327+ * Self-loops introduced by contraction are dropped, and new cross-package edges are recorded.
328+ */
315329 private static void contractVertex (
316330 Graph <VertexInfo , DefaultWeightedEdge > classGraph ,
317331 Graph <VertexInfo , DefaultWeightedEdge > packageGraph ,
@@ -372,6 +386,7 @@ private static void contractVertex(
372386 classGraph .removeVertex (fabricatedVertex );
373387 }
374388
389+ /** Adds or increments a package edge when both class endpoints have distinct, nonempty packages. */
375390 private static void addPackageEdgeIfCrossPackage (
376391 Graph <VertexInfo , DefaultWeightedEdge > packageGraph , VertexInfo classSource , VertexInfo classTarget ) {
377392 String pkgSource = packageName (classSource .getName ());
@@ -400,6 +415,7 @@ private static String packageName(String fqn) {
400415 return lastDot >= 0 ? fqn .substring (0 , lastDot ) : "" ;
401416 }
402417
418+ /** Copies source vertices and edges into the target, adding weights for edges already present. */
403419 private static void mergeGraph (
404420 Graph <VertexInfo , DefaultWeightedEdge > source , Graph <VertexInfo , DefaultWeightedEdge > target ) {
405421 // Add vertices
@@ -422,6 +438,7 @@ private static void mergeGraph(
422438 }
423439 }
424440
441+ /** Maps a source DTO's package-to-class relationships onto the corresponding merged graph edges. */
425442 private static void mergeClassRelationships (
426443 CodebaseGraphDTO dto ,
427444 Graph <VertexInfo , DefaultWeightedEdge > sourceClassGraph ,
0 commit comments