Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException using Bellman-Ford algorithm #124

Closed
miguellopezbecona opened this issue Apr 16, 2015 · 0 comments
Closed

NullPointerException using Bellman-Ford algorithm #124

miguellopezbecona opened this issue Apr 16, 2015 · 0 comments
Assignees
Labels
Milestone

Comments

@miguellopezbecona
Copy link

Executing the following code, using one of the graph of the examples, raises a NullPointerException when using Bellman-Ford algorithm:

/*******************/
String first = "A";
String goal = "F";
List list = new ArrayList<>();
list.add(new Link("A","B",2));
list.add(new Link("A","C",6));
list.add(new Link("B","C",1));
list.add(new Link("B","D",9));
list.add(new Link("B","F",11));
list.add(new Link("C","E",3));
list.add(new Link("D","F",2));
list.add(new Link("E","D",2));
HashBasedHipsterDirectedGraph g = new HashBasedHipsterDirectedGraph<>();
for(Link l : list)
g.connect(l.getSource(), l.getTarget(), l.getWeight());
SearchProblem p = GraphSearchProblem.startingFrom(first).in(g).takeCostsFromEdges().build();
Algorithm.SearchResult o = Hipster.createBellmanFord(p).search(goal);
/**
*****************/
Note: "Link" is a simple bean class with "source", "target" and "weight" fields.

Replacing the algorithm with other such as Dijkstra or Breadth, it works fine.

@pablormier pablormier added the bug label Apr 16, 2015
@pablormier pablormier added this to the v1.0.0 milestone Apr 16, 2015
@pablormier pablormier self-assigned this Apr 16, 2015
@pablormier pablormier modified the milestones: v1.0.0, v1.0.0-rc2 Jul 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants