I am having trouble with priority queue of poll. My try is this:
public int [][] MST(int i, int prim[][], int mst[][], int vertices, int counter, PriorityQueue priorityQueue){
Table table = new Table();
int next_row;
for(int j=0;j<vertices;j++)
{
table.s = i;
table.d = j;
table.w = prim[i][j];
priorityQueue.add(table);
}
table = priorityQueue.poll();
mst[counter][0] = table.s;
mst[counter][1] = table.d;
return mst;
}
Then I got error at priorityQueue.poll(). It says required Table, but found java.lang.Object.
How should I solve this problem?
Use Typecasting as
PriorityQueue prq = new PriorityQueue();
prq.add (new Table (values)) ;
Table data = (Table) prq.poll();