fix(reasoner): remove duplicate vertex (#325)

This commit is contained in:
Donghai 2024-07-15 16:36:07 +08:00 committed by GitHub
parent 884b598c03
commit 2f18a19769
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1490,31 +1490,32 @@ public class LocalRDG extends RDG<LocalRDG> {
debugStartNodeINfos);
}
LocalReasonerResult localReasonerResult = getResult();
java.util.Set<IVertex<IVertexId, IProperty>> vertexSet = new HashSet<>();
java.util.Set<IEdge<IVertexId, IProperty>> edgeSet = new HashSet<>();
this.kgGraphList.forEach(
graph -> {
for (String alias : graph.getVertexAlias()) {
localReasonerResult.getVertexList().addAll(graph.getVertex(alias));
vertexSet.addAll(graph.getVertex(alias));
}
for (String alias : graph.getEdgeAlias()) {
java.util.List<IEdge<IVertexId, IProperty>> edges = graph.getEdge(alias);
for (IEdge<IVertexId, IProperty> edge : edges) {
if (edge instanceof PathEdge) {
if (((PathEdge<?, ?, ?>) edge).getVertexList() != null) {
localReasonerResult
.getVertexList()
.addAll(((PathEdge<IVertexId, IProperty, IProperty>) edge).getVertexList());
vertexSet.addAll(
((PathEdge<IVertexId, IProperty, IProperty>) edge).getVertexList());
}
if (((PathEdge<?, ?, ?>) edge).getEdgeList() != null) {
localReasonerResult
.getEdgeList()
.addAll(((PathEdge<IVertexId, IProperty, IProperty>) edge).getEdgeList());
edgeSet.addAll(((PathEdge<IVertexId, IProperty, IProperty>) edge).getEdgeList());
}
}
localReasonerResult.getEdgeList().add(edge);
edgeSet.add(edge);
}
localReasonerResult.getEdgeList().addAll(graph.getEdge(alias));
}
});
localReasonerResult.getVertexList().addAll(vertexSet);
localReasonerResult.getEdgeList().addAll(edgeSet);
return localReasonerResult;
}