public class

BellmanFord

extends Algorithm<A, S, N extends Node<A, S, N>>
java.lang.Object
   ↳ es.usc.citius.hipster.algorithm.Algorithm<A, S, N extends es.usc.citius.hipster.model.Node<A, S, N>>
     ↳ es.usc.citius.hipster.algorithm.BellmanFord<A, S, C extends java.lang.Comparable<C>, N extends es.usc.citius.hipster.model.CostNode<A, S, C, N>>

Class Overview

Optimized implementation of the Bellman-Ford algorithm. The main difference with the standard version of Bellman-Ford is that this implementation does not relax all edges at each iteration. This implies that the first time the goal state is reached, the cost may not be the optimal one. The optimal cost is only guaranteed when the queue is empty (when bellmanFordIt.hasNext() == false).

Original paper: Bellman, R. "On a routing problem". Quarterly of Applied Mathematics (1958) 16: 87–90.

Summary

Nested Classes
class BellmanFord.Iterator Bellman-Ford iterator. 
Fields
protected boolean checkNegativeCycles
protected N extends CostNode<A, S, C extends Comparable<C>, N> initialNode
protected NodeExpander<A, S, N extends CostNode<A, S, C extends Comparable<C>, N>> nodeExpander
Public Constructors
BellmanFord(N initialNode, NodeExpander<A, S, N> nodeExpander)
Public Methods
N getInitialNode()
NodeExpander<A, S, N> getNodeExpander()
boolean isCheckNegativeCycles()
Iterator iterator()
SearchResult search(Predicate<N> condition)
Executes the search algorithm until the predicate condition is satisfied or there are no more nodes to explore.
void setCheckNegativeCycles(boolean checkNegativeCycles)
void setInitialNode(N initialNode)
void setNodeExpander(NodeExpander<A, S, N> nodeExpander)
[Expand]
Inherited Methods
From class es.usc.citius.hipster.algorithm.Algorithm
From class java.lang.Object
From interface java.lang.Iterable

Fields

protected boolean checkNegativeCycles

protected N extends CostNode<A, S, C extends Comparable<C>, N> initialNode

protected NodeExpander<A, S, N extends CostNode<A, S, C extends Comparable<C>, N>> nodeExpander

Public Constructors

public BellmanFord (N initialNode, NodeExpander<A, S, N> nodeExpander)

Public Methods

public N getInitialNode ()

public NodeExpander<A, S, N> getNodeExpander ()

public boolean isCheckNegativeCycles ()

public Iterator iterator ()

public SearchResult search (Predicate<N> condition)

Executes the search algorithm until the predicate condition is satisfied or there are no more nodes to explore.

Parameters
condition predicate with the boolean condition.

public void setCheckNegativeCycles (boolean checkNegativeCycles)

public void setInitialNode (N initialNode)

public void setNodeExpander (NodeExpander<A, S, N> nodeExpander)