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

Function DiGraph_add_one_node

cpp_easygraph/classes/directed_graph.cpp:129–152  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

127}
128
129node_t DiGraph_add_one_node(DiGraph& self, py::object one_node_for_adding,
130 py::object node_attr = py::dict()) {
131 node_t id;
132 if (self.node_to_id.contains(one_node_for_adding)) {
133 id = self.node_to_id[one_node_for_adding].cast<node_t>();
134 } else {
135 id = ++(self.id);
136 self.id_to_node[py::cast(id)] = one_node_for_adding;
137 self.node_to_id[one_node_for_adding] = id;
138 }
139 py::list items = py::list(node_attr.attr("items")());
140 self.node[id] = node_attr_dict_factory();
141 self.adj[id] = adj_attr_dict_factory();
142 self.pred[id] = adj_attr_dict_factory();
143
144 for (int i = 0; i < len(items); i++) {
145 py::tuple kv = items[i].cast<py::tuple>();
146 py::object pkey = kv[0];
147 std::string weight_key = weight_to_string(pkey);
148 weight_t value = kv[1].cast<weight_t>();
149 self.node[id].insert(std::make_pair(weight_key, value));
150 }
151 return id;
152}
153
154py::object DiGraph_add_node(py::args args, py::kwargs kwargs) {
155 DiGraph& self = args[0].cast<DiGraph&>();

Callers 7

DiGraph_add_nodeFunction · 0.85
DiGraph_add_nodesFunction · 0.85
DiGraph_add_nodes_fromFunction · 0.85
DiGraph_add_one_edgeFunction · 0.85
DiGraph_add_edges_fromFunction · 0.85
DiGraph_nodes_subgraphFunction · 0.85

Calls 1

weight_to_stringFunction · 0.85

Tested by

no test coverage detected