summaryrefslogtreecommitdiffstats
path: root/core/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/slitopologyutils/graph/DefaultEdgeWeigher.java
blob: 92a9172b2ec26422625c8c98456e9d19c4a3ba3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package org.onap.ccsdk.sli.core.slipluginutils.slitopologyutils.graph;

/**
 * Default weigher returns identical weight for every graph edge. Basically it
 * is a hop count weigher.
 * Produces weights of {@link ScalarWeight} type.
 *
 * @param <V> vertex type
 * @param <E> edge type
 */
public class DefaultEdgeWeigher<V extends Vertex, E extends Edge<V>>
        implements EdgeWeigher<V, E> {

    /**
     * Common weight value for any link.
     */
    protected static final double HOP_WEIGHT_VALUE = 1;
    /**
     * Weight value for null path (without links).
     */
    protected static final double NULL_WEIGHT_VALUE = 0;

    /**
     * Default weight based on hop count.
     * {@value #HOP_WEIGHT_VALUE}
     */
    public static final ScalarWeight DEFAULT_HOP_WEIGHT =
            new ScalarWeight(HOP_WEIGHT_VALUE);

    /**
     * Default initial weight.
     * {@value #NULL_WEIGHT_VALUE}
     */
    public static final ScalarWeight DEFAULT_INITIAL_WEIGHT =
            new ScalarWeight(NULL_WEIGHT_VALUE);

    @Override
    public Weight weight(E edge) {
        return DEFAULT_HOP_WEIGHT;
    }

    @Override
    public Weight getInitialWeight() {
        return DEFAULT_INITIAL_WEIGHT;
    }

    @Override
    public Weight getNonViableWeight() {
        return ScalarWeight.NON_VIABLE_WEIGHT;
    }
}