This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Java in General and the fly likes prims algorithm Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "prims algorithm" Watch "prims algorithm" New topic
Author

prims algorithm

ernest mcdermott
Greenhorn

Joined: Mar 05, 2007
Posts: 28
hi every1, im currently trying to do a very basic implementation of prims algorithm.
At present i have an array of nodes (places) and edges (distances between the places) all within the form of an adjacency matrix.
Iv now started Prims algorithm and i am trying to call the first node with the follwoing lines of code, altho it compiles and runs it doesnt do anything. Can any1 please help. Thanks in advance.

String firstnode(String[] nodes){
System.out.print(nodes[n=0]);
return nodes[n=0];
}
ernest mcdermott
Greenhorn

Joined: Mar 05, 2007
Posts: 28
sorry guys, meant to say that what i want is to return that node so that from ther i can work on to compare the edges away from it.
Thanks
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3169
    
  10
That code should print out the value of the first String in the array (although you don't need the 'n=' bit, nodes[0] will be fine). Have you actually put any Strings into the array ?


Joanne
ernest mcdermott
Greenhorn

Joined: Mar 05, 2007
Posts: 28
thanks joanne, it was a foolish mistake on my behalf, got it sorted.
Thanks for your help
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: prims algorithm
 
Similar Threads
Arraylist of variable size in loop?
Question about mem allocation for recursive functions
Static context for AbstractAction question
Graphs and identifying adjacent nodes
Why does this recursion try each permutation?