|
-
April 13th, 2008, 12:31 PM
#1
Adjacency List & Prim's Algo
First, if anyone is willing to help one on one off the forum via phone/chat, please see this post: http://www.codeguru.com/forum/showthread.php?t=450720
As an overview, I need to use an adjacency list/matrix to use Prim's algorithm to find a minimum spanning tree and total weight.
This is an UNdirected graph:
loaf berry(18) fig(5) carrot(6)
orange jack(25) salad(21) berry(10)
carrot fig(2) loaf(6) salad(12)
ivy jack(16) banana(24)
salad carrot(12) orange(21) pizza(28)
pizza jack(18) salad(28) fig(29)
berry orange(10) fig(14) loaf(18) grape(20)
fig berry(14) carrot(2) loaf(5) pizza(29)
grape berry(20) banana(17) jack(10)
jack grape(10) pizza(18) orange(25) ivy(16)
banana ivy(24) grape(17)
so loaf goes to berry, fig, and carrot, with a distance of 18, 5, and 6.
orange is the vertex.
The first step is to setup and store everything inside an adjacency list/matrix.
I have some code for Prim's algo already, but I am not sure how to start this with an adjacency list.
Here's the example output of the input quoted above:
orange -> berry
berry -> fig
fig -> carrot
fig -> loaf
carrot -> salad
berry -> grape
grape -> jack
jack -> ivy
grape -> banana
jack -> pizza
weight: 24
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|