• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

prims algorithm

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ?
 
ernest mcdermott
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks joanne, it was a foolish mistake on my behalf, got it sorted.
Thanks for your help
reply
    Bookmark Topic Watch Topic
  • New Topic