| 514 | } |
| 515 | |
| 516 | py::object DiGraph_nodes_subgraph(py::object self, py::list from_nodes) { |
| 517 | py::object G = self.attr("__class__")(); |
| 518 | Graph& self_ = self.cast<Graph&>(); |
| 519 | DiGraph& G_ = G.cast<DiGraph&>(); |
| 520 | G_.graph.attr("update")(self_.graph); |
| 521 | py::object nodes = self.attr("nodes"); |
| 522 | py::object adj = self.attr("adj"); |
| 523 | for (int i = 0; i < py::len(from_nodes); i++) { |
| 524 | py::object node = from_nodes[i]; |
| 525 | if (self_.node_to_id.contains(node)) { |
| 526 | py::object node_attr = nodes[node]; |
| 527 | DiGraph_add_one_node(G_, node, node_attr); |
| 528 | } |
| 529 | py::object out_edges = adj[node]; |
| 530 | py::list edge_items = py::list(out_edges.attr("items")()); |
| 531 | for (int j = 0; j < py::len(edge_items); j++) { |
| 532 | py::tuple item = edge_items[j].cast<py::tuple>(); |
| 533 | py::object v = item[0]; |
| 534 | py::object edge_attr = item[1]; |
| 535 | if (from_nodes.contains(v)) { |
| 536 | DiGraph_add_one_edge(G_, node, v, edge_attr); |
| 537 | } |
| 538 | } |
| 539 | } |
| 540 | return G; |
| 541 | } |
| 542 | |
| 543 | py::object DiGraph_generate_linkgraph(py::object self, py::object weight){ |
| 544 | DiGraph& G_ = self.cast<DiGraph&>(); |
nothing calls this directly
no test coverage detected