createTestCase1 creates a test case that initially looks like: 0 |(5) 1 (3)/ \(4) 2 3. After keeping 0, 2, and 3, it expects the graph: 0 (3)/ \(4) 2 3.
()
| 201 | // (3)/ \(4) |
| 202 | // 2 3. |
| 203 | func createTestCase1() trimTreeTestcase { |
| 204 | // Create initial graph |
| 205 | graph := &Graph{make(Nodes, 4)} |
| 206 | nodes := graph.Nodes |
| 207 | for i := range nodes { |
| 208 | nodes[i] = createEmptyNode() |
| 209 | } |
| 210 | createEdges(nodes[0], nodes[1]) |
| 211 | createEdges(nodes[1], nodes[2], nodes[3]) |
| 212 | makeEdgeInline(nodes[0].Out, nodes[1]) |
| 213 | makeEdgeInline(nodes[1].Out, nodes[2]) |
| 214 | setEdgeWeight(nodes[0].Out, nodes[1], 5) |
| 215 | setEdgeWeight(nodes[1].Out, nodes[2], 3) |
| 216 | setEdgeWeight(nodes[1].Out, nodes[3], 4) |
| 217 | |
| 218 | // Create expected graph |
| 219 | expected, keep := createExpectedNodes(nodes[0], nodes[2], nodes[3]) |
| 220 | createExpectedEdges(expected[0], expected[1], expected[2]) |
| 221 | makeEdgeInline(expected[0].out, expected[1].node) |
| 222 | makeExpectedEdgeResidual(expected[0], expected[1]) |
| 223 | makeExpectedEdgeResidual(expected[0], expected[2]) |
| 224 | setEdgeWeight(expected[0].out, expected[1].node, 3) |
| 225 | setEdgeWeight(expected[0].out, expected[2].node, 4) |
| 226 | return trimTreeTestcase{ |
| 227 | initial: graph, |
| 228 | expected: expected, |
| 229 | keep: keep, |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | // createTestCase2 creates a test case that initially looks like: |
| 234 | // |
nothing calls this directly
no test coverage detected
searching dependent graphs…