2 * Copyright (c) 2003, the JUNG Project and the Regents of the University
6 * This software is open-source under the BSD license; see either
8 * http://jung.sourceforge.net/license.txt for a description.
10 package edu.uci.ics.jung.algorithms.matrix;
13 import java.util.HashMap;
17 * Implements the basic matrix operations on double-precision values. Assumes
18 * that the edges have a MutableDouble value.
20 * @author Joshua O'Madadhain
22 public class RealMatrixElementOperations<E> implements MatrixElementOperations<E>
24 private Map<E,Number> edgeData = new HashMap<E,Number>();
27 * Creates an instance using the specified edge values.
29 public RealMatrixElementOperations(Map<E,Number> edgeData)
31 this.edgeData = edgeData;
35 * @see MatrixElementOperations#mergePaths(Object, Object)
37 public void mergePaths(E e, Object pathData)
40 Number pd = (Number)pathData;
41 Number ed = edgeData.get(e);
46 edgeData.put(e, ed.doubleValue()+pd.doubleValue());
53 * @see MatrixElementOperations#computePathData(Object, Object)
55 public Number computePathData(E e1, E e2)
57 double d1 = edgeData.get(e1).doubleValue();
58 double d2 = edgeData.get(e2).doubleValue();
63 * @return the edgeData
65 public Map<E, Number> getEdgeData() {