| 144 | } |
| 145 | |
| 146 | static void CheckEdges(Nodes *nodes, Edges *edges, |
| 147 | tensorflow::GraphCycles *gc) { |
| 148 | int count = 0; |
| 149 | for (int i = 0; i != edges->size(); i++) { |
| 150 | int a = (*edges)[i].from; |
| 151 | int b = (*edges)[i].to; |
| 152 | if (!gc->HasEdge(a, b)) { |
| 153 | PrintEdges(edges); |
| 154 | PrintGCEdges(nodes, gc); |
| 155 | LOG(FATAL) << "!gc->HasEdge(" << a << ", " << b << ")"; |
| 156 | } |
| 157 | } |
| 158 | for (int i = 0; i != nodes->size(); i++) { |
| 159 | for (int j = 0; j != nodes->size(); j++) { |
| 160 | int a = (*nodes)[i]; |
| 161 | int b = (*nodes)[j]; |
| 162 | if (gc->HasEdge(a, b)) { |
| 163 | count++; |
| 164 | } |
| 165 | } |
| 166 | } |
| 167 | if (count != edges->size()) { |
| 168 | PrintEdges(edges); |
| 169 | PrintGCEdges(nodes, gc); |
| 170 | LOG(FATAL) << "edges->size() " << edges->size() << " count " << count; |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | // Returns the index of a randomly chosen node in *nodes. |
| 175 | // Requires *nodes be non-empty. |
no test coverage detected