Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Help with Prim's Algorithm in Mathematica

  1. Oct 13, 2008 #1
    This is my project of Spanning Tree by using Prim's Algorithm , I have to implies this problem (#4, PIC is attached) into Mathematica ( I have version 6 btw). Which we never learned in class. Its my Applied Math class, all we do/did is theorems. We never learned a single thing about this program in the class.

    I did take computer programming about two semester ago and according to professor, both program are very similar. But I find it very different. Anyone would like to help me out with this project.

    I'd really appreciate it. Thanks in Advance.

    attachment didn't work, so i just uploaded the pic. Link is below.
    http://img129.imageshack.us/my.php?image=sc3ju5.jpg
     
  2. jcsd
  3. Oct 14, 2008 #2
    anyone?
     
  4. Jan 13, 2009 #3
    This is what im trying to get.
    [​IMG]


    ........and this is what i keep getting.
    [​IMG]
     
  5. Oct 7, 2010 #4
    First of all use Mathematica/combinatorica package. You have to import it. In Mathematica 7,
    In Mathematica 5,
    Then you should create an adjacency list for the graph you mentioned. (I hope you can do that?). After you've created the adjacency list you can create a graph from it using
    . There is a built in algorithm
    Though it uses Kruskal's algorithm. You can easily show any graph using
    To employ Prim's Algorithm, you have to do the following:
    1. How to traverse list of lists
    2. How to write Moduels in Mathematica

    Let me know if it worked.
    Thanks
     
    Last edited: Oct 7, 2010
  6. Oct 7, 2010 #5
    Based on your description of your background, I suggest you not start thinking about what to do with Mathematica yet. I suggest you first try to understand the algorithm until you can write down an EXTREMELY simple list of instructions or directions for someone else to do. Imagine this person understands nothing and can only do the simplest things that you describe exactly how to do and the order to do them in.

    Once you have understood enough that you have created that very simple list of instructions then post that list here. And then begin to think about how you might turn each of those instructions into one or two programming language statements for some simple programming language you might understand.

    Once you have done that then begin to think about how those statements might have a similar statement or two in Mathematica. If you are not sure about whether your Mathematica statement will do what you need then write a couple of lines of Mathematica to test your statement on data that you provide. For example, if you need to find a particular item in a list and you are not sure if your method will work to find that then write a couple of lines to test your method.

    This will probably not give a Mathematica program like an experienced MMA programmer would write, but hopefully it will give you two or three smaller steps that you can accomplish one by one and hopefully will let you accomplish your task.

    I suggest you not let someone tell you the answer, but only ask for hints when you are really stuck and have worked hard on it before asking for the hint you need.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: Help with Prim's Algorithm in Mathematica
  1. Help With Mathematica (Replies: 2)

  2. Mathematica help (Replies: 1)

  3. Help in Mathematica (Replies: 15)

  4. Help with Mathematica? (Replies: 1)

Loading...