Professional Documents
Culture Documents
Practical-3 Aim:: Write A Program To Identify Maximal Independent Set of Any Undirected Graph G
Practical-3 Aim:: Write A Program To Identify Maximal Independent Set of Any Undirected Graph G
Practical-3
Code:
#Input graph
def select_neighbor(vertice):
if vertice in graph.keys():
#print(graph.values())
temp=graph.get(vertice)
temp.append(vertice)
return temp
def maximal_inde_set(graph):
set=graph.keys()
#current=list(graph.keys())[0]
maximal=[]
max=maximal_inde_set(graph)
print("Maximal Independent Set:",max)
INPUT:
OUTPUT: