MCPcopy Create free account
hub / github.com/easy-graph/Easy-Graph / DiGraph_nodes_subgraph

Function DiGraph_nodes_subgraph

cpp_easygraph/classes/directed_graph.cpp:516–541  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

514}
515
516py::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
543py::object DiGraph_generate_linkgraph(py::object self, py::object weight){
544 DiGraph& G_ = self.cast<DiGraph&>();

Callers

nothing calls this directly

Calls 2

DiGraph_add_one_nodeFunction · 0.85
DiGraph_add_one_edgeFunction · 0.85

Tested by

no test coverage detected