Gets the number of ports in the immediate fanout of a node. Count the controlled nodes iff include_controlled_nodes is true.
| 253 | // Gets the number of ports in the immediate fanout of a node. Count the |
| 254 | // controlled nodes iff include_controlled_nodes is true. |
| 255 | int NumFanouts(const NodeDefT& node, bool include_controlled_nodes) const { |
| 256 | int count = 0; |
| 257 | |
| 258 | OutputPort port; |
| 259 | port.node = const_cast<NodeDefT*>(&node); |
| 260 | const int first_port_id = include_controlled_nodes ? -1 : 0; |
| 261 | const int last_port_id = |
| 262 | gtl::FindWithDefault(max_regular_output_port_, &node, -1); |
| 263 | |
| 264 | for (int i = first_port_id; i <= last_port_id; ++i) { |
| 265 | port.port_id = i; |
| 266 | auto it = fanouts_.find(port); |
| 267 | if (it != fanouts_.end()) count += it->second.size(); |
| 268 | } |
| 269 | |
| 270 | return count; |
| 271 | } |
| 272 | |
| 273 | // Gets all the edges in the immediate fanout of a node. Include the |
| 274 | // controlled edges iff include_controlled_edges is true. |