1 /* 2 * Copyright (C) 2016 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 20 /** A utility class to hold various constants used by the Guava Graph library. */ 21 @ElementTypesAreNonnullByDefault 22 final class GraphConstants { 23 GraphConstants()24 private GraphConstants() {} 25 26 static final int EXPECTED_DEGREE = 2; 27 28 static final int DEFAULT_NODE_COUNT = 10; 29 static final int DEFAULT_EDGE_COUNT = DEFAULT_NODE_COUNT * EXPECTED_DEGREE; 30 31 // Load factor and capacity for "inner" (i.e. per node/edge element) hash sets or maps 32 static final float INNER_LOAD_FACTOR = 1.0f; 33 static final int INNER_CAPACITY = 2; // ceiling(EXPECTED_DEGREE / INNER_LOAD_FACTOR) 34 35 // Error messages 36 static final String NODE_NOT_IN_GRAPH = "Node %s is not an element of this graph."; 37 static final String EDGE_NOT_IN_GRAPH = "Edge %s is not an element of this graph."; 38 static final String REUSING_EDGE = 39 "Edge %s already exists between the following nodes: %s, " 40 + "so it cannot be reused to connect the following nodes: %s."; 41 static final String MULTIPLE_EDGES_CONNECTING = 42 "Cannot call edgeConnecting() when parallel edges exist between %s and %s. Consider calling " 43 + "edgesConnecting() instead."; 44 static final String PARALLEL_EDGES_NOT_ALLOWED = 45 "Nodes %s and %s are already connected by a different edge. To construct a graph " 46 + "that allows parallel edges, call allowsParallelEdges(true) on the Builder."; 47 static final String SELF_LOOPS_NOT_ALLOWED = 48 "Cannot add self-loop edge on node %s, as self-loops are not allowed. To construct a graph " 49 + "that allows self-loops, call allowsSelfLoops(true) on the Builder."; 50 static final String NOT_AVAILABLE_ON_UNDIRECTED = 51 "Cannot call source()/target() on a EndpointPair from an undirected graph. Consider calling " 52 + "adjacentNode(node) if you already have a node, or nodeU()/nodeV() if you don't."; 53 static final String EDGE_ALREADY_EXISTS = "Edge %s already exists in the graph."; 54 static final String ENDPOINTS_MISMATCH = 55 "Mismatch: unordered endpoints cannot be used with directed graphs"; 56 57 /** Singleton edge value for {@link Graph} implementations backed by {@link ValueGraph}s. */ 58 enum Presence { 59 EDGE_EXISTS 60 } 61 } 62