Change the psuedocode into an actual python program The inpu

Change the psuedocode into an actual python program. The input is an adjacency list.

Algorithm 1 Dominate (L): Set nonblack be an empty object to host non-black vertices Let ds be an empty set for hosting the dominating set: Let color be a length-n array, all of whose slots are initialized to white for each vertex i in the graph do nonblack insert (i, L[i]. length + 1) end for (v, whiteDeg) leftarrow nonblack. getmax() while whiteDeg > 0 do Save v to ds if color [v] == white then. for each neighbor j of vertex v do nonblack.decreasevalue(j, 1) end for end if for each neighbor j of vertex v do if color [j] == white then for each neighbor k vertex j do nonblack.decreaseValue (k, 1) end for color [j] leftarrow gray end if end for color[v] leftarrow back (v, whiteDeg) leftarow nonblack.getmax() end while return ds

Solution

A)

import time
def getTextFile(set non black be an empty object to host non-black vertices):
from ds be nan emptynset for hosting he domiating set
array n=wgite;
int i;
Debug(i,L[i].length+1)
end for
(v,white deg) non black .get max()
while
{
whitedeg>0 do
save v to ds
if
color [v]==white then
for(each neighbor j of vertex v do
non black.decreasevalue(j,1)
color[j]--gray
color[v]--black
(v,white deg) non black.get max()
}
return ds

Change the psuedocode into an actual python program. The input is an adjacency list. Algorithm 1 Dominate (L): Set nonblack be an empty object to host non-black

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site