MinimumSpanningTree throws NullPointerException?

If not, it will fail If you add the test I gave in the other answer, you will get an MST of the connected subgraphs - but it's (obviously) impossible to build an MST for the whole graph.

If not, it will fail... If you add the test I gave in the other answer, you will get an MST of the connected subgraphs - but it's (obviously) impossible to build an MST for the whole graph.

– Arve Feb 27 at 21:44 @Alexander E: Connected = "there is a path from any point to any other point in the graph" – Arve Feb 27 at 21:51 Aha, well, yes the test case creates a single graph not sub graphs by my understanding – Alexander E Feb 27 at 21:52 You could test it by doing a search through the graph (e.g. Breadth first), and verify that all nodes are actually visited. If they are not, there's an error with the test set. Otherwise, DisjSet could be the source of your problems :-) – Arve Feb 27 at 21:55.

Try calling pq.take() and not pq.poll(). Poll will return null on an empty queue, take will block until there is an element available.

Somehow take doesn't seem to exist for me + I noticed the priority queue seems to be empty somehow – Alexander E Feb 27 at 21:22 That's the point: take will block until it has an element. – Leo Izen Feb 27 at 21:24 My bad: PriorityQueue download.oracle. Com/javase/6/docs/api/java/util/… doesn't have it, but PriorityBlockingQueue download.oracle.Com/javase/6/docs/api/java/util/concurrent/… does.

You might want to use that. – Leo Izen Feb 27 at 21:27 PriorityBlockingQueue offers take(), but Alexander's implementation is not using threads, so should there be a need for this? – Arve Feb 27 at 21:29 maybe while(edgesAccepted 0) is a better solution to my problem then?

(well not a solution) – Alexander E Feb 27 at 21:46.

Haven't tested your code, but at least PriorityQueue.poll() returns null if the queue is empty. How about changing: while(edgesAccepted 0).

Yes, that fails the test. Seems my priority queue is empty somehow – Alexander E Feb 27 at 21:23.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions