Skip to content
This repository was archived by the owner on Jun 18, 2026. It is now read-only.

Commit 0d5b44d

Browse files
fix: ensure edge-only vertices are tracked in ParseResult.getVertices()
When vertices appear only in edge lines (not in the 'nodes' section), they were added to the JUNG graph by addEdge() but missing from ParseResult.getVertices(). This caused inconsistencies where graph.getVertexCount() != result.getVertices().size(), breaking downstream code that relies on the vertex set for iteration, metrics, or export. Now edge endpoints are explicitly added to both the vertex set and the graph before edge insertion, ensuring consistency regardless of whether vertices are declared in the nodes section.
1 parent 29802be commit 0d5b44d

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

Gvisual/src/gvisual/GraphFileParser.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,11 @@ public static ParseResult parse(String filePath, Predicate<String> visibleFilter
164164
typeList.add(curEdge);
165165
}
166166

167+
// Ensure edge endpoints are tracked in the vertex set
168+
// (they may not appear in the "nodes" section)
169+
if (vertices.add(parts[1])) g.addVertex(parts[1]);
170+
if (vertices.add(parts[2])) g.addVertex(parts[2]);
171+
167172
// Only add to graph if this type is visible
168173
if (visibleFilter.test(parts[0])) {
169174
g.addEdge(curEdge, parts[1], parts[2]);

0 commit comments

Comments
 (0)