Hi, I am creating a simple program using Kruskals Algorithm
I am stuck on creating almost like a structure to hold the data for the algorithm.
For example, I need an arraylist of:
edges which contains
{
int from;
int to;
int weight;
}
I have tried many ways but cannot do it. I need to be able to add data like
e.g. if i have an arraylist called myEdges
i want to be able to do myEdges.add and be able to add a value for each of the elements inside the edge type.
I will later need to sort the data by the weight.
this is what i have done so far
public class Edge { public int from; public int to; public int weight; public Edge(int from, int to, int cost) { this.from = from; this.to = to; this.weight = cost; } } ArrayList<Edge> myEdges = new ArrayList<Edge>();
but i am not sure how to add data to it.
thank you.