- java.lang.Object
-
- xyz.cofe.collection.graph.PathFinder<N,E>
-
- Type Parameters:
N- Тип вершиныE- Тип ребра
public class PathFinder<N,E> extends Object implements Iterator<Path<N,E>>
Поиск путей в графе.Производит обход графа формируя возможные пути. Обход производится по крайчащим путям. Конечная вершина поиска определяется пользователем данного класса.
За один вызов next() выдает один возможный путь из указанной точки.
- Author:
- gocha
-
-
Field Summary
Fields Modifier and Type Field Description protected Comparator<Path<N,E>>comparatorprotected Path.DirectiondirectionНаправление движенияprotected SingleDirectedGraph<N,E>graphГраф в котором производится поискprotected List<Path<N,E>>pathsСписок путей используемых в поиске.
-
Constructor Summary
Constructors Constructor Description PathFinder(SingleDirectedGraph<N,E> graph, N start, Path.Direction direction, Comparator<Path<N,E>> comparator)КонструкторPathFinder(SingleDirectedGraph<N,E> graph, N start, Path.Direction direction, Function<Edge<N,E>,Double> getWeight)Конструктор
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Path<N,E>append(Path<N,E> path, Edge<N,E> e)Добавляет ребро в конец путиprotected Comparator<Path<N,E>>createComparatorFrom(Function<Edge<N,E>,Double> getWeight)Создание Comparator для путиprotected Path<N,E>createPath()Создаает путьprotected List<Path<N,E>>createPathsList()Создает список путейprotected doublegetIntWeightOf(Path<N,E> path, Function<Edge<N,E>,Double> getWeight)Полчение веса путиprotected Iterable<Edge<N,E>>getNextEdges(N n)Извлекает исходящие ребра/дуги из вершины n в соот. движению.booleanhasNext()Path<N,E>next()voidremove()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Iterator
forEachRemaining
-
-
-
-
Field Detail
-
graph
protected SingleDirectedGraph<N,E> graph
Граф в котором производится поиск
-
direction
protected Path.Direction direction
Направление движения
-
paths
protected List<Path<N,E>> paths
Список путей используемых в поиске. Используются их конечные вершины.
-
comparator
protected Comparator<Path<N,E>> comparator
-
-
Constructor Detail
-
PathFinder
public PathFinder(SingleDirectedGraph<N,E> graph, N start, Path.Direction direction, Function<Edge<N,E>,Double> getWeight)
Конструктор- Parameters:
graph- Одно направленный графstart- Начальная вершина путиdirection- Направление движенияgetWeight- Получение веса ребра, вес должен быть положительным или равен нулю
-
PathFinder
public PathFinder(SingleDirectedGraph<N,E> graph, N start, Path.Direction direction, Comparator<Path<N,E>> comparator)
Конструктор- Parameters:
graph- Одно направленный графstart- Начальная вершина путиdirection- Направление движенияcomparator- Сравнение длины путей
-
-
Method Detail
-
getIntWeightOf
protected double getIntWeightOf(Path<N,E> path, Function<Edge<N,E>,Double> getWeight)
Полчение веса пути- Parameters:
path- ПутьgetWeight- Получение веса ребра- Returns:
- Вес пути
-
createComparatorFrom
protected Comparator<Path<N,E>> createComparatorFrom(Function<Edge<N,E>,Double> getWeight)
Создание Comparator для пути- Parameters:
getWeight- Получение веса ребра- Returns:
- Comparator
-
createPathsList
protected List<Path<N,E>> createPathsList()
Создает список путей- Returns:
- Список путей
-
append
protected Path<N,E> append(Path<N,E> path, Edge<N,E> e)
Добавляет ребро в конец пути- Parameters:
path- Путьe- Ребро- Returns:
- Новый путь
-
getNextEdges
protected Iterable<Edge<N,E>> getNextEdges(N n)
Извлекает исходящие ребра/дуги из вершины n в соот. движению.- Parameters:
n- Вершина- Returns:
- Ребра/дуги направления движения.
-
-