Skip to content
Snippets Groups Projects
Commit 26714299 authored by Octave Perrin's avatar Octave Perrin
Browse files

bind graph

parent 167aafee
No related branches found
No related tags found
No related merge requests found
This commit is part of merge request !245. Comments created here will be created in the context of that merge request.
...@@ -379,17 +379,17 @@ public: ...@@ -379,17 +379,17 @@ public:
* Get the ranked list of nodes in the GraphView. * Get the ranked list of nodes in the GraphView.
* Node ranking if performed the following: * Node ranking if performed the following:
* - The root node is put in the ranked list first (rank 1); * - The root node is put in the ranked list first (rank 1);
* - Then, its childs (in order of outputs) are added in the ranked list; * - Then, its children (in order of outputs) are added in the ranked list;
* - Then, its parents (in order of inputs) are added in the ranked list; * - Then, its parents (in order of inputs) are added in the ranked list;
* - The childs and parents of the next node in the ranked list are then * - The children and parents of the next node in the ranked list are then
* added to the list, and so on. * added to the list, and so on.
* - Any remaining nodes have no path to the root node and are added in * - Any remaining nodes have no path to the root node and are added in
* arbitrary order. In this case, the ranking is not garanteed to be unique. * arbitrary order. In this case, the ranking is not guaranteed to be unique.
* *
* If the ranking cannot be garanteed to be unique, the second item indicates * If the ranking cannot be guaranteed to be unique, the second item indicates
* the rank from which unicity cannot be garanteed. * the rank from which unicity cannot be guaranteed.
* @return std::pair<std::vector<NodePtr>, size_t> Pair with the list of ranked * @return std::pair<std::vector<NodePtr>, size_t> Pair with the list of ranked
* nodes and the size of the ranked sub-list where unicity is garanteed. * nodes and the size of the ranked sub-list where unicity is guaranteed.
*/ */
std::pair<std::vector<NodePtr>, size_t> getRankedNodes() const; std::pair<std::vector<NodePtr>, size_t> getRankedNodes() const;
......
...@@ -141,6 +141,7 @@ void init_GraphView(py::module& m) { ...@@ -141,6 +141,7 @@ void init_GraphView(py::module& m) {
:return: Whether any replacement has been made. :return: Whether any replacement has been made.
:rtype: bool :rtype: bool
)mydelimiter") )mydelimiter")
.def("clone", &GraphView::clone, .def("clone", &GraphView::clone,
R"mydelimiter( R"mydelimiter(
Clone the current GraphView using a callback function for the Node cloning, allowing to specify how each Clone the current GraphView using a callback function for the Node cloning, allowing to specify how each
...@@ -154,12 +155,15 @@ void init_GraphView(py::module& m) { ...@@ -154,12 +155,15 @@ void init_GraphView(py::module& m) {
:return: Cloned GraphView :return: Cloned GraphView
:rtype: GraphView :rtype: GraphView
)mydelimiter") )mydelimiter")
.def("get_nodes", &GraphView::getNodes, .def("get_nodes", &GraphView::getNodes,
R"mydelimiter( R"mydelimiter(
Get the Nodes in the GraphView. Get the Nodes in the GraphView.
:return: List of the GraphView's Nodes :return: List of the GraphView's Nodes
:rtype: List[Node] :rtype: List[Node]
)mydelimiter") )mydelimiter")
.def("get_node", &GraphView::getNode, py::arg("node_name"), .def("get_node", &GraphView::getNode, py::arg("node_name"),
R"mydelimiter( R"mydelimiter(
Get the Node with the corresponding name if it is in the GraphView. Get the Node with the corresponding name if it is in the GraphView.
...@@ -190,11 +194,52 @@ void init_GraphView(py::module& m) { ...@@ -190,11 +194,52 @@ void init_GraphView(py::module& m) {
// return py::none(); // return py::none();
// } // }
// }) // })
.def("get_ranked_nodes", &GraphView::getRankedNodes) .def("get_ranked_nodes", &GraphView::getRankedNodes,
.def("get_ranked_nodes_name", &GraphView::getRankedNodesName, py::arg("format"), py::arg("mark_non_unicity") = true) R"mydelimiter(
Get the ranked list of nodes in the GraphView.
Node ranking if performed the following:
- The root node is put in the ranked list first (rank 1);
- Then, its children (in order of outputs) are added in the ranked list;
- Then, its parents (in order of inputs) are added in the ranked list;
- The children and parents of the next node in the ranked list are then added to the list, and so on.
- Any remaining nodes have no path to the root node and are added in arbitrary order. In this case, the ranking is not guaranteed to be unique.
If the ranking cannot be guaranteed to be unique, the second item indicates
the rank from which unicity cannot be guaranteed.
:return: Pair with the list of ranked nodes and the size of the ranked sub-list where unicity is guaranteed.
:rtype: (Node, int)
)mydelimiter")
.def("get_ranked_nodes_name", &GraphView::getRankedNodesName, py::arg("format"), py::arg("mark_non_unicity") = true,
R"mydelimiter(
//TODO
Get the nodes name according to the GraphView nodes ranking.
@param format The formatting string to be used with fmt::format().
@details The usable positional arguments are the following:
{0} node name, {1} node type, {2} rank, {3} type rank
@param markNonUnicity If true, non unique ranking is prefixed with "?"
@return std::map<NodePtr, std::string> A map with the corresponding names
*/
)mydelimiter")
.def("set_dataformat", &GraphView::setDataFormat, py::arg("dataformat")) .def("set_dataformat", &GraphView::setDataFormat, py::arg("dataformat"))
; ;
m.def("get_connected_graph_view", &getConnectedGraphView); m.def("get_connected_graph_view", &getConnectedGraphView,
R"mydelimiter(
Create a GraphView containing all nodes with a path to given Node.
:param node: Initial node to construct the graph.
:type node: Node
:return: GraphView GraphView containing all nodes with a path to node.
:rtype: GraphView
)mydelimiter");
} }
} // namespace Aidge } // namespace Aidge
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment