0

I am trying to use a Java library (Hipster) with Scala. Running the example on the front page, I get this type error message which I can't make sense of:

My attempt so far was to try convert Java <==> Scala Doubles and Strings to no avail.

<console>:23: error: type mismatch;
 found   : es.usc.citius.hipster.model.problem.SearchProblem[scala.Double,String,es.usc.citius.hipster.model.impl.WeightedNode[scala.Double,String,java.lang.Double]]
 required: es.usc.citius.hipster.model.problem.SearchProblem[A,S,N]
       val sol = Hipster.createDijkstra(pX)

Code sample:

import es.usc.citius.hipster.algorithm.Hipster
import es.usc.citius.hipster.model.problem.SearchProblem

val graph = GraphBuilder.create[String,Double]().connect(
  "A").to("B").withEdge(4.0).
  connect("A").to("C").withEdge(2.0).
  connect("B").to("C").withEdge(5.0).
  connect("B").to("D").withEdge(10.0).
  connect("C").to("E").withEdge(3.0).
  connect("D").to("F").withEdge(11.0).
  connect("E").to("D").withEdge(4.0).
  createDirectedGraph()

// Create the search problem. For graph problems, just use
// the GraphSearchProblem util class to generate the problem with ease


val pX = GraphSearchProblem.startingFrom("A").in(graph).takeCostsFromEdges().build();

// Search the shortest path from "A" to "F"
val sol = Hipster.createDijkstra(pX)
2
  • Try passing java.lang.Double instead of a simple Double Commented Apr 20, 2020 at 5:09
  • That didn't help. interestingly, createDepthFirstSearch works (instead of createDijkstra). The generic signature is bit different. Will look into it more. Commented Apr 20, 2020 at 17:51

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.