Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid self-edges and self-subclassing #172

Merged
merged 3 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/edge_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,10 @@ export default class QueryEdgeManager {
subjectMatch = _.intersection([...subjectIDs], execSubjectCuries).length;
objectMatch = _.intersection([...objectIDs], execObjectCuries).length;
//if both ends match then keep record
if (subjectMatch && objectMatch) {

// Don't keep self-edges
const selfEdge = [...subjectIDs].some((curie) => objectIDs.has(curie));
if (subjectMatch && objectMatch && !selfEdge) {
keep.push(record);
}
});
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ export default class TRAPIQueryHandler {
subclassCuries.forEach(([original, expanded]) => {
const subject = nodeID;
const object = primaryIDsByOriginalID[original];
// Don't keep self-subclass
if (subject === object) return;
const subclassEdgeID = `expanded-${subject}-subclass_of-${object}`;
if (subclassEdgeID in this.bteGraph.edges) return;
const subclassEdge = new KGEdge(subclassEdgeID, {
Expand Down
Loading