• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2014 The Guava Authors
3  *
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
7  *
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.
15  */
16 
17 package com.google.common.graph;
18 
19 import java.util.Arrays;
20 import java.util.Collection;
21 import org.junit.runner.RunWith;
22 import org.junit.runners.Parameterized;
23 import org.junit.runners.Parameterized.Parameters;
24 
25 /** Tests for an undirected {@link StandardMutableGraph}. */
26 @AndroidIncompatible
27 @RunWith(Parameterized.class)
28 public class StandardMutableUndirectedGraphTest extends AbstractStandardUndirectedGraphTest {
29 
30   @Parameters(name = "allowsSelfLoops={0}, incidentEdgeOrder={1}")
parameters()31   public static Collection<Object[]> parameters() {
32     return Arrays.asList(
33         new Object[][] {
34           {false, ElementOrder.unordered()},
35           {true, ElementOrder.unordered()},
36           {false, ElementOrder.stable()},
37           {true, ElementOrder.stable()},
38         });
39   }
40 
41   private final boolean allowsSelfLoops;
42   private final ElementOrder<Integer> incidentEdgeOrder;
43 
StandardMutableUndirectedGraphTest( boolean allowsSelfLoops, ElementOrder<Integer> incidentEdgeOrder)44   public StandardMutableUndirectedGraphTest(
45       boolean allowsSelfLoops, ElementOrder<Integer> incidentEdgeOrder) {
46     this.allowsSelfLoops = allowsSelfLoops;
47     this.incidentEdgeOrder = incidentEdgeOrder;
48   }
49 
50   @Override
createGraph()51   public MutableGraph<Integer> createGraph() {
52     return GraphBuilder.undirected()
53         .allowsSelfLoops(allowsSelfLoops)
54         .incidentEdgeOrder(incidentEdgeOrder)
55         .build();
56   }
57 
58   @Override
addNode(Integer n)59   final void addNode(Integer n) {
60     graphAsMutableGraph.addNode(n);
61   }
62 
63   @Override
putEdge(Integer n1, Integer n2)64   final void putEdge(Integer n1, Integer n2) {
65     graphAsMutableGraph.putEdge(n1, n2);
66   }
67 }
68