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

Function _add_one_node

cpp_easygraph/classes/graph.cpp:58–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56}
57
58node_t _add_one_node(Graph& self, py::object one_node_for_adding, py::object node_attr = py::dict()) {
59 node_t id;
60 if (self.node_to_id.contains(one_node_for_adding)) {
61 id = self.node_to_id[one_node_for_adding].cast<node_t>();
62 } else {
63 id = ++(self.id);
64 self.id_to_node[py::cast(id)] = one_node_for_adding;
65 self.node_to_id[one_node_for_adding] = id;
66 }
67 py::list items = py::list(node_attr.attr("items")());
68 self.node[id] = node_attr_dict_factory();
69 self.adj[id] = adj_attr_dict_factory();
70 for (int i = 0; i < len(items); i++) {
71 py::tuple kv = items[i].cast<py::tuple>();
72 py::object pkey = kv[0];
73 std::string weight_key = weight_to_string(pkey);
74 weight_t value = kv[1].cast<weight_t>();
75 self.node[id].insert(std::make_pair(weight_key, value));
76 }
77 return id;
78}
79
80py::object Graph_add_node(py::args args, py::kwargs kwargs) {
81 Graph& self = args[0].cast<Graph&>();

Callers 7

Graph_add_nodeFunction · 0.85
Graph_add_nodesFunction · 0.85
Graph_add_nodes_fromFunction · 0.85
_add_one_edgeFunction · 0.85
Graph_add_edges_fromFunction · 0.85
Graph_nodes_subgraphFunction · 0.85

Calls 1

weight_to_stringFunction · 0.85

Tested by

no test coverage detected