Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
Merge rest of lazy mifs
Browse files Browse the repository at this point in the history
  • Loading branch information
iopapamanoglou committed Nov 8, 2024
1 parent 7b6c1d9 commit 2e80456
Show file tree
Hide file tree
Showing 23 changed files with 866 additions and 784 deletions.
6 changes: 6 additions & 0 deletions src/faebryk/core/cpp/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ class Counter:
class Graph:
def __init__(self) -> None: ...
def get_edges(self, arg: GraphInterface, /) -> dict[GraphInterface, Link]: ...
@property
def edges(self) -> list[tuple[GraphInterface, GraphInterface, Link]]: ...
def get_gifs(self) -> set[GraphInterface]: ...
def invalidate(self) -> None: ...
@property
def node_count(self) -> int: ...
Expand Down Expand Up @@ -120,6 +123,9 @@ class LinkDirectConditionalFilterResult(enum.Enum):

FILTER_FAIL_UNRECOVERABLE = 2

class LinkDirectDerived(LinkDirect):
pass

class LinkFilteredException(Exception):
pass

Expand Down
4 changes: 4 additions & 0 deletions src/faebryk/core/cpp/include/graph/graph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <nanobind/stl/pair.h>
#include <nanobind/stl/shared_ptr.h>
#include <nanobind/stl/string.h>
#include <nanobind/stl/tuple.h>
#include <nanobind/stl/unordered_map.h>
#include <nanobind/stl/unordered_set.h>
#include <nanobind/stl/vector.h>
Expand Down Expand Up @@ -194,6 +195,9 @@ class Graph {

std::string repr();

Set<GI_ref> get_gifs();
std::vector<std::tuple<GI_ref_weak, GI_ref_weak, Link_ref>> all_edges();

// Algorithms
std::unordered_set<Node_ref> node_projection();
std::vector<std::pair<Node_ref, std::string>>
Expand Down
8 changes: 8 additions & 0 deletions src/faebryk/core/cpp/src/graph/graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,11 @@ Graph::bfs_visit(std::function<bool(std::vector<GI_ref_weak> &, Link_ref)> filte

return visited;
}

Set<GI_ref> Graph::get_gifs() {
return this->v;
}

std::vector<std::tuple<GI_ref_weak, GI_ref_weak, Link_ref>> Graph::all_edges() {
return this->e;
}
3 changes: 3 additions & 0 deletions src/faebryk/core/cpp/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ PYMOD(m) {
nb::class_<Graph>(m, "Graph")
.def(nb::init<>())
.def("get_edges", &Graph::get_edges, nb::rv_policy::reference)
.def_prop_ro("edges", &Graph::all_edges, nb::rv_policy::reference)
.def("get_gifs", &Graph::get_gifs, nb::rv_policy::reference)
.def("invalidate", &Graph::invalidate)
.def_prop_ro("node_count", &Graph::node_count)
.def_prop_ro("edge_count", &Graph::edge_count)
Expand Down Expand Up @@ -141,6 +143,7 @@ PYMOD(m) {
nb::class_<LinkDirectConditional, LinkDirect>(m, "LinkDirectConditional")
.def(nb::init<LinkDirectConditional::FilterF, bool>(), "filter"_a,
"needs_only_first_in_path"_a = false);
nb::class_<LinkDirectDerived, LinkDirect>(m, "LinkDirectDerived");

nb::exception<LinkDirectConditional::LinkFilteredException>(m,
"LinkFilteredException");
Expand Down
1 change: 1 addition & 0 deletions src/faebryk/core/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
LinkDirect,
LinkDirectConditional,
LinkDirectConditionalFilterResult,
LinkDirectDerived,
LinkFilteredException,
LinkNamedParent,
LinkParent,
Expand Down
Loading

0 comments on commit 2e80456

Please sign in to comment.