blob: 6acc9864e90d4a31aa195a4776e018c143b9bd4a [file] [log] [blame]
Thomas Vachuska24c849c2014-10-27 09:53:05 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2014-present Open Networking Laboratory
Thomas Vachuska24c849c2014-10-27 09:53:05 -07003 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07004 * 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 Vachuska24c849c2014-10-27 09:53:05 -07007 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07008 * 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 Vachuska24c849c2014-10-27 09:53:05 -070015 */
tome3489412014-08-29 02:30:38 -070016package org.onlab.graph;
17
tome3489412014-08-29 02:30:38 -070018import java.util.Set;
19
tom144de692014-08-29 11:38:44 -070020import static com.google.common.collect.ImmutableSet.of;
21
tome3489412014-08-29 02:30:38 -070022/**
23 * Base class for various graph-related tests.
24 */
25public 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");
tom2e1f0712014-08-29 13:32:00 -070035 static final TestVertex Z = new TestVertex("Z");
tome3489412014-08-29 02:30:38 -070036
tom0633d682014-09-10 12:10:03 -070037 protected Graph<TestVertex, TestEdge> graph;
tome3489412014-08-29 02:30:38 -070038
39 protected EdgeWeight<TestVertex, TestEdge> weight =
40 new EdgeWeight<TestVertex, TestEdge>() {
tomc53fa0d2014-08-29 11:57:11 -070041 @Override
42 public double weight(TestEdge edge) {
43 return edge.weight();
44 }
45 };
tome3489412014-08-29 02:30:38 -070046
47 protected void printPaths(Set<Path<TestVertex, TestEdge>> paths) {
48 for (Path p : paths) {
49 System.out.println(p);
50 }
51 }
52
tom0633d682014-09-10 12:10:03 -070053 protected Set<TestVertex> vertexes() {
tom144de692014-08-29 11:38:44 -070054 return of(A, B, C, D, E, F, G, H);
tome3489412014-08-29 02:30:38 -070055 }
56
57 protected Set<TestEdge> edges() {
tom144de692014-08-29 11:38:44 -070058 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));
tome3489412014-08-29 02:30:38 -070064 }
65
66}