Skip to content

Commit

Permalink
Merge pull request #533 from SkepticMystic/no-direction
Browse files Browse the repository at this point in the history
no direction
  • Loading branch information
SkepticMystic authored Apr 23, 2024
2 parents 43a3e1e + dab0500 commit 2b09fb2
Show file tree
Hide file tree
Showing 109 changed files with 4,730 additions and 2,974 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ Media related to Breacrumbs. Thanks to everyone for sharing!

## Credits

- [mProjectsCode](https://github.com/mProjectsCode): For their various PRs, insightful suggestions, and efficient graph-traversal algorithms
- [mProjectsCode](https://github.com/mProjectsCode): For their PRs, insightful suggestions, and efficiency improvements.
- [HEmile](https://github.com/HEmile): For their PRs, and helpful discussions on graph-theory.

<!-- NOTE: This heading is linked to in the manifest.fundingUrl. Be sure to change that if updating the heading label -->

Expand Down
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

84 changes: 8 additions & 76 deletions src/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
import { ListIndex } from "src/commands/list_index";
import {
ARROW_DIRECTIONS,
DIRECTIONS,
type Direction,
} from "src/const/hierarchies";
import type { BCEdgeAttributes } from "src/graph/MyMultiGraph";
import { Traverse } from "src/graph/traverse";
import type { Hierarchy } from "src/interfaces/hierarchies";
import { active_file_store } from "src/stores/active_file";
import {
get_field_hierarchy,
get_opposite_direction,
} from "src/utils/hierarchies";
import { get } from "svelte/store";
import type BCPlugin from "../main";
import { has_edge_attrs, type EdgeAttrFilters } from "src/graph/utils";

export class BCAPI {
plugin: BCPlugin;
Expand All @@ -23,41 +11,23 @@ export class BCAPI {
this.plugin = plugin;
}

public DIRECTIONS = DIRECTIONS;
public ARROW_DIRECTIONS = ARROW_DIRECTIONS;
get fields() {
return this.plugin.settings.edge_fields;
}

// TODO
public buildObsGraph = () => {
throw new Error("Not implemented");
};
get field_groups() {
return this.plugin.settings.edge_field_groups;
}

public refresh = () => this.plugin.refresh();
/** @deprecated Use refresh */
public refreshIndex = this.refresh;

/** @deprecated Filter edges of plugin.graph instead */
public getSubInDirs = (dirs: Direction[], g = this.plugin.graph) => {};

/** @deprecated Filter edges of plugin.graph instead */
public getSubForFields = (fields: string[], g = this.plugin.graph) => {};

public all_paths_depth_first = (
start_node = get(active_file_store)?.path,
graph = this.plugin.graph,
attrs?: EdgeAttrFilters,
) => {
if (!start_node) throw new Error("No active file");

return Traverse.all_paths("depth_first", graph, start_node, (e) =>
has_edge_attrs(e, attrs),
);
};

/** @deprecated Use all_paths_depth_first instead */
public dfsAllPaths = this.all_paths_depth_first;

public nest_all_paths = Traverse.nest_all_paths;
public flatten_all_paths = Traverse.flatten_all_paths;
public build_tree = Traverse.build_tree;
public breadth_first_traversal = Traverse.breadth_first;

public create_list_index = (
start_node = get(active_file_store)?.path,
Expand All @@ -83,42 +53,4 @@ export class BCAPI {

/** @deprecated Use get_neighbours instead */
public getMatrixNeighbours = this.get_neighbours;

public get_opposite_direction = get_opposite_direction;
/** @deprecated Use get_opposite_direction */
public getOppDir = this.get_opposite_direction;

public get_opposite_fields = (field: string) => {
const field_hierarchy = get_field_hierarchy(
this.plugin.settings.hierarchies,
field,
);
if (!field_hierarchy) {
console.error(
"BCAPI.getOppFields: field_hierarchy not found",
field,
);
return [];
}

return this.plugin.settings.hierarchies[field_hierarchy.hierarchy_i]
.dirs[get_opposite_direction(field_hierarchy.dir)];
};

/** @deprecated Use get_opposite_fields */
public getOppFields = this.get_opposite_fields;

public get_field_hierarchy = (field: string) =>
get_field_hierarchy(this.plugin.settings.hierarchies, field);

/** @deprecated Use get_field_hierarchy */
public getFieldInfo = this.get_field_hierarchy;

/** @deprecated Filter plugin.settings.hierarchies instead */
public getFields = (dir: Direction) => {};

/** @deprecated Map plugin.settings.hierachies instead */
public iterateHiers(
cb: (hier: Hierarchy, dir: Direction, field: string) => void,
) {}
}
Loading

0 comments on commit 2b09fb2

Please sign in to comment.