| 206 | } |
| 207 | |
| 208 | py::object Graph_nbunch_iter(py::object self, py::object nbunch) { |
| 209 | py::object bunch = py::none(); |
| 210 | if (nbunch.is_none()) { |
| 211 | bunch = self.attr("adj").attr("__iter__")(); |
| 212 | } else if (self.contains(nbunch)) { |
| 213 | py::list nbunch_wrapper = py::list(); |
| 214 | nbunch_wrapper.append(nbunch); |
| 215 | bunch = nbunch_wrapper.attr("__iter__")(); |
| 216 | } else { |
| 217 | py::list nbunch_list = py::list(nbunch), nodes_list = py::list(); |
| 218 | for (int i = 0; i < py::len(nbunch_list); i++) { |
| 219 | py::object n = nbunch_list[i]; |
| 220 | if (self.contains(n)) { |
| 221 | nodes_list.append(n); |
| 222 | } |
| 223 | } |
| 224 | bunch = nbunch_list.attr("__iter__")(); |
| 225 | } |
| 226 | return bunch; |
| 227 | } |
| 228 | |
| 229 | void _add_one_edge(Graph& self, py::object u_of_edge, py::object v_of_edge, py::object edge_attr) { |
| 230 | node_t u, v; |