blob: b838421d640432a1f10a37742cd68d2fbc19ce89 [file] [log] [blame]
Thomas Vachuska24c849c2014-10-27 09:53:05 -07001/*
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07002 * Copyright 2014 Open Networking Laboratory
Thomas Vachuska24c849c2014-10-27 09:53:05 -07003 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07004 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
Thomas Vachuska24c849c2014-10-27 09:53:05 -07007 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07008 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
Thomas Vachuska24c849c2014-10-27 09:53:05 -070015 */
tome3489412014-08-29 02:30:38 -070016package org.onlab.graph;
17
18import java.util.Map;
19import java.util.Set;
20
21/**
22 * Representation of a graph path search algorithm.
23 *
24 * @param <V> vertex type
25 * @param <E> edge type
26 */
27public interface GraphPathSearch<V extends Vertex, E extends Edge<V>> {
28
29 /**
30 * Abstraction of a path search result.
31 */
32 public interface Result<V extends Vertex, E extends Edge<V>> {
33
34 /**
35 * Returns the search source.
36 *
37 * @return search source
38 */
39 public V src();
40
41 /**
42 * Returns the search destination, if was was given.
43 *
44 * @return optional search destination
45 */
46 public V dst();
47
48 /**
49 * Returns the set of paths produced as a result of the graph search.
50 *
51 * @return set of paths
52 */
53 Set<Path<V, E>> paths();
54
55 /**
56 * Returns bindings of each vertex to its parent edges in the path.
57 *
58 * @return map of vertex to its parent edge bindings
59 */
60 public Map<V, Set<E>> parents();
61
62 /**
63 * Return a bindings of each vertex to its cost in the path.
64 *
65 * @return map of vertex to path cost bindings
66 */
67 public Map<V, Double> costs();
68 }
69
70 /**
71 * Searches the specified graph.
72 *
73 * @param graph graph to be searched
74 * @param src optional source vertex
75 * @param dst optional destination vertex; if null paths to all vertex
76 * destinations will be searched
77 * @param weight optional edge-weight; if null cost of each edge will be
78 * assumed to be 1.0
79 * @return search results
80 */
81 Result<V, E> search(Graph<V, E> graph, V src, V dst, EdgeWeight<V, E> weight);
82
83}