Line | Hits | Source |
---|---|---|
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; | |
11 | ||
12 | import edu.uci.ics.jung.algorithms.MatrixElementOperations; | |
13 | import edu.uci.ics.jung.graph.Edge; | |
14 | import edu.uci.ics.jung.utils.MutableDouble; | |
15 | import edu.uci.ics.jung.utils.UserData; | |
16 | ||
17 | /** | |
18 | * Implements the basic matrix operations on double-precision values. Assumes | |
19 | * that the edges have a MutableDouble value. | |
20 | * | |
21 | * @author Joshua O'Madadhain | |
22 | */ | |
23 | public class RealMatrixElementOperations implements MatrixElementOperations | |
24 | { | |
25 | private String EDGE_KEY; | |
26 | ||
27 | public RealMatrixElementOperations(String edge_key) | |
28 | 3 | { |
29 | 3 | EDGE_KEY = edge_key; |
30 | 3 | } |
31 | ||
32 | /** | |
33 | * @see MatrixElementOperations#mergePaths(Edge, Object) | |
34 | */ | |
35 | public void mergePaths(Edge e, Object pathData) | |
36 | { | |
37 | 21 | MutableDouble pd = (MutableDouble)pathData; |
38 | 21 | MutableDouble ed = (MutableDouble)e.getUserDatum(EDGE_KEY); |
39 | 21 | if (ed == null) |
40 | 18 | e.addUserDatum(EDGE_KEY, pd, UserData.SHARED); |
41 | else | |
42 | 3 | ed.add(pd.doubleValue()); |
43 | 21 | } |
44 | ||
45 | /** | |
46 | * @see MatrixElementOperations#computePathData(Edge, Edge) | |
47 | */ | |
48 | public Object computePathData(Edge e1, Edge e2) | |
49 | { | |
50 | 21 | double d1 = ((MutableDouble)e1.getUserDatum(EDGE_KEY)).doubleValue(); |
51 | 21 | double d2 = ((MutableDouble)e2.getUserDatum(EDGE_KEY)).doubleValue(); |
52 | 21 | return new MutableDouble(d1*d2); |
53 | } | |
54 | } |
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |