blob: e8df185cc34dcfacff4137d605d6f845b265d4c0 [file] [log] [blame]
tome3489412014-08-29 02:30:38 -07001package org.onlab.graph;
2
3import java.util.Map;
4import java.util.Set;
5
6/**
7 * Representation of a graph path search algorithm.
8 *
9 * @param <V> vertex type
10 * @param <E> edge type
11 */
12public interface GraphPathSearch<V extends Vertex, E extends Edge<V>> {
13
14 /**
15 * Abstraction of a path search result.
16 */
17 public interface Result<V extends Vertex, E extends Edge<V>> {
18
19 /**
20 * Returns the search source.
21 *
22 * @return search source
23 */
24 public V src();
25
26 /**
27 * Returns the search destination, if was was given.
28 *
29 * @return optional search destination
30 */
31 public V dst();
32
33 /**
34 * Returns the set of paths produced as a result of the graph search.
35 *
36 * @return set of paths
37 */
38 Set<Path<V, E>> paths();
39
40 /**
41 * Returns bindings of each vertex to its parent edges in the path.
42 *
43 * @return map of vertex to its parent edge bindings
44 */
45 public Map<V, Set<E>> parents();
46
47 /**
48 * Return a bindings of each vertex to its cost in the path.
49 *
50 * @return map of vertex to path cost bindings
51 */
52 public Map<V, Double> costs();
53 }
54
55 /**
56 * Searches the specified graph.
57 *
58 * @param graph graph to be searched
59 * @param src optional source vertex
60 * @param dst optional destination vertex; if null paths to all vertex
61 * destinations will be searched
62 * @param weight optional edge-weight; if null cost of each edge will be
63 * assumed to be 1.0
64 * @return search results
65 */
66 Result<V, E> search(Graph<V, E> graph, V src, V dst, EdgeWeight<V, E> weight);
67
68}