May 2021 1 65 Report
Primms algorithm, pseudo code help?

hello world "HA! bet your all sick of that ain't cha!"

I have an assignment to implement Prims algorithm using a graph ADT we've made prior.

below is my current pseudo code:

create a variable smallest " smallest =9999"

create a variable for current smallest edge "default set yo the first edge we use aka graph[1]"

for(every vertex in vertexList) {

for(every vertex in adjacency lists "aka, every vertex adjacent to vertex"){

if(vertex <smaller) current vertex = smallest;

smallest edge = current edge

}

}

}

DELETE SMALLEST EDGE FROM GRAPH;

add smallest edge to edge return list;

add new vertex associated with edge to vertex list;

if vertex list is = to total number of edges

return edgelist

the problem I am having is the DELETE SMALLEST EDGE from graph bit, I dont have a function to handle this, that is, I dont have a function that will delete a refference to this node in the adjacency lists of other vertexs.

ex:

I take away edge AB and store it in a list, HOWEVER, I cannot think of a way to delete A from B's agency list. what should I do?

Please enter comments
Please enter your name.
Please enter the correct email address.
You must agree before submitting.

Answers & Comments


Helpful Social

Copyright © 2024 QUIZLS.COM - All rights reserved.