generated from obsidianmd/obsidian-sample-plugin
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Complete all existing implied relationships
- Loading branch information
1 parent
a28eca9
commit 3d31ae5
Showing
8 changed files
with
87 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import type { ImpliedEdgeBuilder } from "src/interfaces/graph"; | ||
|
||
export const _add_implied_edges_cousin_is_sibling: ImpliedEdgeBuilder = ( | ||
graph, | ||
plugin, | ||
) => { | ||
plugin.settings.hierarchies.forEach((hierarchy, hierarchy_i) => { | ||
if (!hierarchy.implied_relationships.cousin_is_sibling) { | ||
return; | ||
} | ||
|
||
graph.forEachNode((source_id) => { | ||
graph | ||
.get_dir_chains_path( | ||
source_id, | ||
["up", "same", "down"], | ||
(edge) => | ||
edge.attr.hierarchy_i === hierarchy_i && | ||
edge.attr.explicit && | ||
// Don't include the current source_id in the path | ||
edge.target_id !== source_id, | ||
) | ||
.forEach((path) => { | ||
console.log("path", path); | ||
graph.addDirectedEdge(source_id, path.last()!.target_id, { | ||
dir: "same", | ||
hierarchy_i, | ||
explicit: false, | ||
implied_kind: "cousin_is_sibling", | ||
field: hierarchy.dirs["same"].at(0) ?? null, | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
return {}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import type { ImpliedEdgeBuilder } from "src/interfaces/graph"; | ||
|
||
export const _add_implied_edges_siblings_parent_is_parent: ImpliedEdgeBuilder = | ||
(graph, plugin) => { | ||
plugin.settings.hierarchies.forEach((hierarchy, hierarchy_i) => { | ||
if (!hierarchy.implied_relationships.siblings_parent_is_parent) { | ||
return; | ||
} | ||
|
||
graph.forEachNode((source_id) => { | ||
graph | ||
.get_dir_chains_path( | ||
source_id, | ||
["same", "up"], | ||
(edge) => | ||
edge.attr.hierarchy_i === hierarchy_i && | ||
edge.attr.explicit && | ||
// Don't include the current source_id in the path | ||
edge.target_id !== source_id, | ||
) | ||
.forEach((path) => { | ||
console.log("path", path); | ||
graph.addDirectedEdge( | ||
source_id, | ||
path.last()!.target_id, | ||
{ | ||
dir: "up", | ||
hierarchy_i, | ||
explicit: false, | ||
implied_kind: "siblings_parent_is_parent", | ||
field: hierarchy.dirs["up"].at(0) ?? null, | ||
}, | ||
); | ||
}); | ||
}); | ||
}); | ||
|
||
return {}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters