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

Function DiGraph_add_one_edge

cpp_easygraph/classes/directed_graph.cpp:276–300  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

274}
275
276void DiGraph_add_one_edge(DiGraph& self, py::object u_of_edge,
277 py::object v_of_edge, py::object edge_attr) {
278 node_t u, v;
279 if (!self.node_to_id.contains(u_of_edge)) {
280 u = DiGraph_add_one_node(self, u_of_edge);
281 } else {
282 u = self.node_to_id[u_of_edge].cast<node_t>();
283 }
284 if (!self.node_to_id.contains(v_of_edge)) {
285 v = DiGraph_add_one_node(self, v_of_edge);
286 } else {
287 v = self.node_to_id[v_of_edge].cast<node_t>();
288 }
289 py::list items = py::list(edge_attr.attr("items")());
290 self.adj[u][v] = node_attr_dict_factory();
291 self.pred[v][u] = edge_attr_dict_factory();
292 for (int i = 0; i < len(items); i++) {
293 py::tuple kv = items[i].cast<py::tuple>();
294 py::object pkey = kv[0];
295 std::string weight_key = weight_to_string(pkey);
296 weight_t value = kv[1].cast<weight_t>();
297 self.adj[u][v].insert(std::make_pair(weight_key, value));
298 self.pred[v][u].insert(std::make_pair(weight_key, value));
299 }
300}
301
302py::object DiGraph_add_edge(py::args args, py::kwargs kwargs) {
303 DiGraph& self = args[0].cast<DiGraph&>();

Callers 4

DiGraph_add_edgeFunction · 0.85
DiGraph_add_edgesFunction · 0.85
DiGraph_nodes_subgraphFunction · 0.85

Calls 2

DiGraph_add_one_nodeFunction · 0.85
weight_to_stringFunction · 0.85

Tested by

no test coverage detected