blob: 9f5326d4ec7a73290ce905af376a4915244a174b [file] [log] [blame]
Andrey Komarov2398d962016-09-26 15:11:23 +03001/*
2 * Copyright 2016-present Open Networking Laboratory
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
17package org.onlab.graph;
18
19/**
20 * Abstraction of a graph edge weight.
21 */
22public interface Weight extends Comparable<Weight> {
23
24 /**
25 * Merges the given weight with this one returning a new aggregated
26 * weight.
27 *
28 * @param otherWeight weight to add
29 * @return aggregated weight
30 */
31 Weight merge(Weight otherWeight);
32
33 /**
34 * Subtracts the given weight from this one and produces a new weight.
35 *
36 * @param otherWeight weight to subtract
37 * @return residual weight
38 */
39 Weight subtract(Weight otherWeight);
40
41 /**
42 * Returns true if the weighted subject (link/path) can be traversed; false otherwise.
43 *
44 * @return true if weight is adequate, false if weight is infinite
45 */
46 boolean isViable();
47
48 /**
49 * Returns true if the weight is negative (means that aggregated
50 * path cost will decrease if we add weighted subject to it).
51 *
52 * @return true if the weight is negative, false otherwise
53 */
54 boolean isNegative();
55}