blob: 01e65ba20cda516caa2944b9bdeb3ec34903177c [file] [log] [blame]
Thomas Vachuska24c849c2014-10-27 09:53:05 -07001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
tome3489412014-08-29 02:30:38 -070019package org.onlab.graph;
20
tome3489412014-08-29 02:30:38 -070021import java.util.Set;
22
tom144de692014-08-29 11:38:44 -070023import static com.google.common.collect.ImmutableSet.of;
24
tome3489412014-08-29 02:30:38 -070025/**
26 * Base class for various graph-related tests.
27 */
28public class GraphTest {
29
30 static final TestVertex A = new TestVertex("A");
31 static final TestVertex B = new TestVertex("B");
32 static final TestVertex C = new TestVertex("C");
33 static final TestVertex D = new TestVertex("D");
34 static final TestVertex E = new TestVertex("E");
35 static final TestVertex F = new TestVertex("F");
36 static final TestVertex G = new TestVertex("G");
37 static final TestVertex H = new TestVertex("H");
tom2e1f0712014-08-29 13:32:00 -070038 static final TestVertex Z = new TestVertex("Z");
tome3489412014-08-29 02:30:38 -070039
tom0633d682014-09-10 12:10:03 -070040 protected Graph<TestVertex, TestEdge> graph;
tome3489412014-08-29 02:30:38 -070041
42 protected EdgeWeight<TestVertex, TestEdge> weight =
43 new EdgeWeight<TestVertex, TestEdge>() {
tomc53fa0d2014-08-29 11:57:11 -070044 @Override
45 public double weight(TestEdge edge) {
46 return edge.weight();
47 }
48 };
tome3489412014-08-29 02:30:38 -070049
50 protected void printPaths(Set<Path<TestVertex, TestEdge>> paths) {
51 for (Path p : paths) {
52 System.out.println(p);
53 }
54 }
55
tom0633d682014-09-10 12:10:03 -070056 protected Set<TestVertex> vertexes() {
tom144de692014-08-29 11:38:44 -070057 return of(A, B, C, D, E, F, G, H);
tome3489412014-08-29 02:30:38 -070058 }
59
60 protected Set<TestEdge> edges() {
tom144de692014-08-29 11:38:44 -070061 return of(new TestEdge(A, B, 1), new TestEdge(A, C, 3),
62 new TestEdge(B, D, 2), new TestEdge(B, C, 1),
63 new TestEdge(B, E, 4), new TestEdge(C, E, 1),
64 new TestEdge(D, H, 5), new TestEdge(D, E, 1),
65 new TestEdge(E, F, 1), new TestEdge(F, D, 1),
66 new TestEdge(F, G, 1), new TestEdge(F, H, 1));
tome3489412014-08-29 02:30:38 -070067 }
68
69}