Algorithms

Moderators: None (Apply to moderate this forum)
Number of threads: 402
Number of posts: 786

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
MST algorithm Posted by Xenoglaux on 6 Jan 2009 at 9:59 PM
Hello,

I've wrote a code for MST with prim's
I wonder if i can change the output from

int graph[8][8]={{0,1,99,1,99,99,99,99},
{1,0,1,99,1,99,1,99},
{99,1,0,1,1,99,99,99},
{1,99,1,0,99,99,99,99},
{99,1,1,99,0,1,99,1},
{99,99,99,99,1,0,1,1},
{99,1,99,99,99,1,0,1},
{99,99,99,99,1,1,1,0}};

to something like this

int data[Total][3]={ {1,2,3},{1,5,2},{1,6,5},{1,10,1},
{2,3,2,},{2,5,2},{2,10,4},
{3,4,8},{3,10,7},
{4,5,3},{4,9,4},{4,8,8},
{5,6,6},{5,9,3},
{6,7,1},{6,9,1},
{7,9,5},{7,8,9},{8,9,6} };
i mean not only i can input 0 ,1 and 99

but i can input this something like 2 ,3 5 and so on...
should i change the code? to vertices matrix? or is there any possible way for me just to input 2 ,3 ,5 and so on?

my currently codes just respond to 0,1 and 99. but when i just put the number it seems very normal the output. It's just i don't know how to write the input like the 2nd conditions.
Thanks
Report
Re: MST algorithm Posted by Xenoglaux on 8 Jan 2009 at 6:21 AM
problem solved...




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.