S
sanoBabu
Hi all
My Java code tries to read a text file of the form -
"Source_node Dest_node distance" and then based on the distance between
those nodes, try to find the minimal spanning tree.
I've already created a class called Node which has source_node and
dest_node and simple accessor/mutator methods.
I've also created an Edge class which represents the distance between
the 2 nodes. Edge has one constructor -
public Edge(Node d, double cost);
I've also created a class called Graph which basically has no
constructor and has the following methods-
public void addEdge(String s,String d,double weight);
public Node getNode(String nodeName);
private Map aNodeMap = new HashMap(); //Maps string to Node
To proceed for the solution, I read the file -> parse contents -> then
I add the "source destination weight" to the graph object using -
g.addEdge(source,dest,weight);
Honestly I don't know how I can tackle the solution after that.
After adding the edges, do I just run the minimal spanning tree
algorithm (g.prim()) on the Graph or do I have to do something more?
ThAnks.
SanoBabu
My Java code tries to read a text file of the form -
"Source_node Dest_node distance" and then based on the distance between
those nodes, try to find the minimal spanning tree.
I've already created a class called Node which has source_node and
dest_node and simple accessor/mutator methods.
I've also created an Edge class which represents the distance between
the 2 nodes. Edge has one constructor -
public Edge(Node d, double cost);
I've also created a class called Graph which basically has no
constructor and has the following methods-
public void addEdge(String s,String d,double weight);
public Node getNode(String nodeName);
private Map aNodeMap = new HashMap(); //Maps string to Node
To proceed for the solution, I read the file -> parse contents -> then
I add the "source destination weight" to the graph object using -
g.addEdge(source,dest,weight);
Honestly I don't know how I can tackle the solution after that.
After adding the edges, do I just run the minimal spanning tree
algorithm (g.prim()) on the Graph or do I have to do something more?
ThAnks.
SanoBabu