| 546 | } |
| 547 | |
| 548 | py::object Graph_nodes_subgraph(py::object self, py::list from_nodes) { |
| 549 | py::object G = self.attr("__class__")(); |
| 550 | Graph& self_ = self.cast<Graph&>(); |
| 551 | Graph& G_ = G.cast<Graph&>(); |
| 552 | G_.graph.attr("update")(self_.graph); |
| 553 | py::object nodes = self.attr("nodes"); |
| 554 | py::object adj = self.attr("adj"); |
| 555 | for (int i = 0; i < py::len(from_nodes); i++) { |
| 556 | py::object node = from_nodes[i]; |
| 557 | if (self_.node_to_id.contains(node)) { |
| 558 | py::object node_attr = nodes[node]; |
| 559 | _add_one_node(G_, node, node_attr); |
| 560 | } |
| 561 | py::object out_edges = adj[node]; |
| 562 | py::list edge_items = py::list(out_edges.attr("items")()); |
| 563 | for (int j = 0; j < py::len(edge_items); j++) { |
| 564 | py::tuple item = edge_items[j].cast<py::tuple>(); |
| 565 | py::object v = item[0]; |
| 566 | py::object edge_attr = item[1]; |
| 567 | if (from_nodes.contains(v)) { |
| 568 | _add_one_edge(G_, node, v, edge_attr); |
| 569 | } |
| 570 | } |
| 571 | } |
| 572 | return G; |
| 573 | } |
| 574 | |
| 575 | py::object Graph_ego_subgraph(py::object self, py::object center) { |
| 576 | py::list neighbors_of_center = py::list(self.attr("all_neighbors")(center)); |
nothing calls this directly
no test coverage detected