Thomas Vachuska | 24c849c | 2014-10-27 09:53:05 -0700 | [diff] [blame] | 1 | /* |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 2 | * Copyright 2014 Open Networking Laboratory |
Thomas Vachuska | 24c849c | 2014-10-27 09:53:05 -0700 | [diff] [blame] | 3 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
Thomas Vachuska | 24c849c | 2014-10-27 09:53:05 -0700 | [diff] [blame] | 7 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
Thomas Vachuska | 24c849c | 2014-10-27 09:53:05 -0700 | [diff] [blame] | 15 | */ |
tom | e348941 | 2014-08-29 02:30:38 -0700 | [diff] [blame] | 16 | package org.onlab.graph; |
| 17 | |
tom | e348941 | 2014-08-29 02:30:38 -0700 | [diff] [blame] | 18 | import java.util.Set; |
| 19 | |
tom | 144de69 | 2014-08-29 11:38:44 -0700 | [diff] [blame] | 20 | import static com.google.common.collect.ImmutableSet.of; |
| 21 | |
tom | e348941 | 2014-08-29 02:30:38 -0700 | [diff] [blame] | 22 | /** |
| 23 | * Base class for various graph-related tests. |
| 24 | */ |
| 25 | public class GraphTest { |
| 26 | |
| 27 | static final TestVertex A = new TestVertex("A"); |
| 28 | static final TestVertex B = new TestVertex("B"); |
| 29 | static final TestVertex C = new TestVertex("C"); |
| 30 | static final TestVertex D = new TestVertex("D"); |
| 31 | static final TestVertex E = new TestVertex("E"); |
| 32 | static final TestVertex F = new TestVertex("F"); |
| 33 | static final TestVertex G = new TestVertex("G"); |
| 34 | static final TestVertex H = new TestVertex("H"); |
tom | 2e1f071 | 2014-08-29 13:32:00 -0700 | [diff] [blame] | 35 | static final TestVertex Z = new TestVertex("Z"); |
tom | e348941 | 2014-08-29 02:30:38 -0700 | [diff] [blame] | 36 | |
tom | 0633d68 | 2014-09-10 12:10:03 -0700 | [diff] [blame] | 37 | protected Graph<TestVertex, TestEdge> graph; |
tom | e348941 | 2014-08-29 02:30:38 -0700 | [diff] [blame] | 38 | |
| 39 | protected EdgeWeight<TestVertex, TestEdge> weight = |
| 40 | new EdgeWeight<TestVertex, TestEdge>() { |
tom | c53fa0d | 2014-08-29 11:57:11 -0700 | [diff] [blame] | 41 | @Override |
| 42 | public double weight(TestEdge edge) { |
| 43 | return edge.weight(); |
| 44 | } |
| 45 | }; |
tom | e348941 | 2014-08-29 02:30:38 -0700 | [diff] [blame] | 46 | |
| 47 | protected void printPaths(Set<Path<TestVertex, TestEdge>> paths) { |
| 48 | for (Path p : paths) { |
| 49 | System.out.println(p); |
| 50 | } |
| 51 | } |
| 52 | |
tom | 0633d68 | 2014-09-10 12:10:03 -0700 | [diff] [blame] | 53 | protected Set<TestVertex> vertexes() { |
tom | 144de69 | 2014-08-29 11:38:44 -0700 | [diff] [blame] | 54 | return of(A, B, C, D, E, F, G, H); |
tom | e348941 | 2014-08-29 02:30:38 -0700 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | protected Set<TestEdge> edges() { |
tom | 144de69 | 2014-08-29 11:38:44 -0700 | [diff] [blame] | 58 | return of(new TestEdge(A, B, 1), new TestEdge(A, C, 3), |
| 59 | new TestEdge(B, D, 2), new TestEdge(B, C, 1), |
| 60 | new TestEdge(B, E, 4), new TestEdge(C, E, 1), |
| 61 | new TestEdge(D, H, 5), new TestEdge(D, E, 1), |
| 62 | new TestEdge(E, F, 1), new TestEdge(F, D, 1), |
| 63 | new TestEdge(F, G, 1), new TestEdge(F, H, 1)); |
tom | e348941 | 2014-08-29 02:30:38 -0700 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | } |