Prim's Algorithm for MST: File IO Error Programming Software Development by r1409 …adjacencyList; // 100000 is the maximum vertexes void read(); int Prim(int at); bool add(pListIt &dest, int val…edges and weights of the MST: \n\n"; Prim(1); fclose(fp); system("PAUSE"); return 0… } //Prims Algoritm to create the minimal spanning tree int Prim(int at) { int i = 0; memset(tree, 0… Prim's algorithm and Kruskal's algorithm program help Programming Software Development by thinkerman …trouble with creating a program based on Prim's algorithm. This is the program and…a][b]=weight[b][a]=w; } } void prim() { int current,totalvisited,mincost,i; current=1…"<<p[i]; } main() { creategraph(); prim(); getch(); } error C4430: missing type specifier - int … Re: Prim's algorithm and Kruskal's algorithm program help Programming Software Development by thinkerman …. It took me a while to make the program. Since Prim's algorithm and Kruskal's algorithm are similiar, I decided… to use the Prim's algorithm code and rework it to use Kruskal's… Re: Prim's algorithm and Kruskal's algorithm program help Programming Software Development by happyuk … excellent sources of information in understanding the workings of Kruskal, Prim etc for finding minmal spanning trees: http://en.wikipedia.org… Prim Algorithm Implementation Programming Software Development by naamurad I have been looking for Prim Algorithm on daniweb.com website and I found multiple threads …dead but still unsolved. Few people needs expalination of Prim Algorithm and others need its working code. Well, to help… everyout out, here is a link to working Prim's Algorithm code which is easier to understand. http://in… Prim's Algorithm Implementation on Graph. Programming Software Development by zindgi66 … <graphics.h> int main() { initwindow(1366, 768, "Prim's Algorithm"); int midx,midy; // /**************Node 0 creation***************/ midx… Algorithm Proof, Prim vs. Kruskal (the same?) Programming Computer Science by drichird … class, my question is this: Is the proof for Prim's algorithm any different than for Kruskal? I understand both… Kruskal (e.g. Wikipedia), but trouble finding proofs for Prim. The Kruskal proof is as far as I can see…the MST morphs into Kruskal Is the proof for Prim identical? Since the Prim algorithm is more constrained, it seems to me… Re: Algorithm Proof, Prim vs. Kruskal (the same?) Programming Computer Science by sarehu … not an MST. [QUOTE]Is the proof for Prim identical? Since the Prim algorithm is more constrained, it seems to me there… should be a simpler proof for Prim?[/QUOTE] It's pretty much the same kind of idea…. (And the proof in both cases is short anyway.) For Prim's algorithm, let S be the set of nodes in… help for the prim algorithm Programming Software Development by pplteo …; //distance of the MST public Prim() { super("Prim"); legend.Init(); legend.AddEdge… { return cost; } /************************************************* * Run one step of Prim's algorithm. * *************************************************/ public void step() { //no … Re: help for the prim algorithm Programming Software Development by thekashyap Usually you would save in a file named Prim.java then execute: > javac Prim.java If this gives any compilation errors you'll sove them and do again. Then run it using: > java Prim Re: :-O Prim's Algo Programming Software Development by peter_budo there is that funny thing called [URL="http://www.google.co.uk/search?hl=en&q=Prim%27s+Algorithm+Implementation&btnG=Google+Search&meta="]google search [/URL]and it does bring lot of resources like [URL="http://en.wikipedia.org/wiki/Prim's_algorithm"]wikipedia[/URL] proof of kruskal's and prim's algorithm Community Center Say Hello! by mukeshkr.mishra hello buddy out there! i want the proof of prim's and kruskal's algorithm in theory and with example so please help me out thanks in advance :-O Prim's Algo Programming Software Development by Kashif Any one knows different types of Prim's Algorithm Implementation. Help me to find the error in Prim code Programming Software Development by chuong3a Help me to find the error in Prim code, thanks. [CODE] #include <iostream.h> #include <… Re: Help me to find the error in Prim code Programming Software Development by chuong3a Help me to run by step the Prim code, thanks. [CODE] #include <iostream.h> #include <… Spanning Trees: Prim's and Kruskal's Algorithm Programming Software Development by floatingDivs … mistake (if I have). Here are my edges for [B]Prim's Algorithm[/B] (1,2) - (1,5) - (5, 7) - (7… Re: Spanning Trees: Prim's and Kruskal's Algorithm Programming Software Development by cherry4life i think for prim's algorithm one last edge is missing. 5-6 Re: Prim's Algorithm for MST: File IO Error Programming Software Development by daviddoria First, why not change the headers to [code] #include <memory.h> #include <cstdio> #include <cstdlib> //required for system() #include <iostream> [/code] to use the "new" way. Also, I think the "c++ way" is to use cout and endl instead of printf and \n. Now to the main problem The first output ("… Re: Prim's Algorithm for MST: File IO Error Programming Software Development by r1409 thanks Dave the reason i am using printf is that i'm not sure of the syntax to use with cout statements when writing to output file, for instance, i don't know how to do this using cout and out statements: [QUOTE]printf( " %d) %d - %d -> %d \n",i, edges[curent].from,edges[curent].to, edges[curent].weight);[/QUOTE] thanks for the … Re: Prim's Algorithm for MST: File IO Error Programming Software Development by daviddoria Here is how you use ofstream: [url]http://www.java2s.com/Code/Cpp/File/Toreadorwritetoafileyouincludefstream.htm[/url] I'd definitely stop using fopen :) Dave Re: Prim's algorithm and Kruskal's algorithm program help Programming Software Development by Ancient Dragon line 71 must be `int main()` Re: Prim's algorithm and Kruskal's algorithm program help Programming Software Development by np complete If you want to follow Standard then replace `#include<stdio.h>` with `#include<cstdio>` Re: Prim's algorithm and Kruskal's algorithm program help Programming Software Development by thinkerman Thanks for the solution Ancient Dragon. I'll try to create the program for Kruskal's Algorithm and post it here if I encounter any errors. I also replaced #include<stdio.h> with #include<cstdio>. Feel free to suggest any other changes as long as they don't radically change the output. Re: Prim's algorithm and Kruskal's algorithm program help Programming Software Development by Ancient Dragon Just briefly looking at your program, on line 34, what's the value of m? Answer: undetermined because you failed to set its value to something (using an uninitialized variable). Next problem is that arrays have valid indexes as 0, 1, 2, 3, ... N-1. Your loops should start at 0, not at 1, and continue until < N, not <= N. Re: Prim's algorithm and Kruskal's algorithm program help Programming Software Development by WaltP It really helps to [format your code](http://www.gidnetwork.com/b-38.html) so others can follow it. Formatting also helps *you* when you get an error like "end of file during compile" of "else without if"... Also, **conio.h** is non-standard and should be avoided. You certainly don't *need* it in these programs. Re: Prim's algorithm and Kruskal's algorithm program help Programming Software Development by TrustyTony Agreed, WaltP. As example, here is what Code::Blocks AStyle plugin makes out of your code #include<iostream> #include<cstdio> #include<conio.h> using namespace std; int weight[20][20],visited[20],d[20],p[20]; int v,e; void creategraph() { int i,j,a,b,w; cout<<"Enter … Re: Prim's algorithm and Kruskal's algorithm program help Programming Software Development by thinkerman #include<iostream> #include<stdlib.h> using namespace std; int weight[20][20],visited[20],d[20],p[20]; int v,e; void creategraph() { int i,j,a,b,w; cout<<"Enter number of vertices: "; cin>>v; cout<<"\… Re: Prim's algorithm and Kruskal's algorithm program help Programming Software Development by Bob > warning C4700: uninitialized local variable 'n' used line 39 32. int cost[10][10],i,j,k,n,c,visit,visited[10],l,v,count1,vst,p,dup1,dup2; 39. for(i=0;i<n;i++) You're using n in an expression in line 39, for (i=0; i<n; i++), but it hasn't yet been initialised, so it holds an unknown garbage value. When i is … Re: Prim's algorithm and Kruskal's algorithm program help Programming Software Development by thinkerman What should n be initialized to? Can it be zero? Where do I place the initialation in the program? Re: Prim's algorithm and Kruskal's algorithm program help Programming Software Development by Bob > What should n be initialized to? Can it be zero? Where do I place the initialation in the program? It can be initialised to whatever valid value you wish, anywhere prior to first use (currently line 39). What was your intention when you wrote the loop? What purpose is it intended to serve?