Fix checkstyle warnings in netconf-cli
[controller.git] / third-party / net.sf.jung2 / src / main / java / edu / uci / ics / jung / algorithms / matrix / RealMatrixElementOperations.java
1 /*
2 * Copyright (c) 2003, the JUNG Project and the Regents of the University 
3 * of California
4 * All rights reserved.
5 *
6 * This software is open-source under the BSD license; see either
7 * "license.txt" or
8 * http://jung.sourceforge.net/license.txt for a description.
9 */
10 package edu.uci.ics.jung.algorithms.matrix;
11
12
13 import java.util.HashMap;
14 import java.util.Map;
15
16 /**
17  * Implements the basic matrix operations on double-precision values.  Assumes
18  * that the edges have a MutableDouble value.
19  * 
20  * @author Joshua O'Madadhain
21  */
22 public class RealMatrixElementOperations<E> implements MatrixElementOperations<E>
23 {
24     private Map<E,Number> edgeData = new HashMap<E,Number>();
25
26     /**
27      * Creates an instance using the specified edge values.
28      */
29     public RealMatrixElementOperations(Map<E,Number> edgeData)
30     {
31         this.edgeData = edgeData;
32     }
33
34         /**
35          * @see MatrixElementOperations#mergePaths(Object, Object)
36          */
37         public void mergePaths(E e, Object pathData) 
38     {
39
40         Number pd = (Number)pathData;
41         Number ed = edgeData.get(e);
42         if (ed == null) {
43                 edgeData.put(e, pd);
44
45         } else {
46                 edgeData.put(e, ed.doubleValue()+pd.doubleValue());
47
48         }
49
50         }
51
52         /**
53          * @see MatrixElementOperations#computePathData(Object, Object)
54          */
55         public Number computePathData(E e1, E e2) 
56     {
57         double d1 = edgeData.get(e1).doubleValue();
58         double d2 = edgeData.get(e2).doubleValue();
59         return d1*d2;
60         }
61
62         /**
63          * @return the edgeData
64          */
65         public Map<E, Number> getEdgeData() {
66                 return edgeData;
67         }
68 }