1 /*
2 * Created on Apr 2, 2004
3 *
4 * Copyright (c) 2004, The JUNG Authors
5 *
6 * All rights reserved.
7 *
8 * This software is open-source under the BSD license; see either
9 * "license.txt" or
10 * https://github.com/jrtom/jung/blob/master/LICENSE for a description.
11 */
12 package edu.uci.ics.jung.algorithms.shortestpath;
13
14 import java.util.Map;
15
16
17 /**
18 * An interface for classes which calculate the distance between
19 * one vertex and another.
20 *
21 * @author Joshua O'Madadhain
22 */
23 public interface Distance<V>
24 {
25 /**
26 * Returns the distance from the <code>source</code> vertex to the
27 * <code>target</code> vertex. If <code>target</code> is not reachable from
28 * <code>source</code>, returns null.
29 *
30 * @param source the vertex from which distance is to be measured
31 * @param target the vertex to which distance is to be measured
32 * @return the distance from {@code source} to {@code target}
33 */
34 Number getDistance(V source, V target);
35
36 /**
37 * Returns a <code>Map</code> which maps each vertex in the graph (including
38 * the <code>source</code> vertex) to its distance (represented as a Number)
39 * from <code>source</code>. If any vertex is not reachable from
40 * <code>source</code>, no distance is stored for that vertex.
41 *
42 * @param source the vertex from which distances are to be measured
43 * @return a {@code Map} of the distances from {@code source} to other vertices in the graph
44 */
45 Map<V, Number> getDistanceMap(V source);
46 }