Question: def add _ edge _ to _ graph ( unique _ weights, edge _ weight ) : if edge _ weight not in unique _

def add_edge_to_graph(unique_weights, edge_weight):
if edge_weight not in unique_weights:
unique_weights.add(edge_weight)
return True
return False
def assign_labels(n, k):
# initialize an empty list to store vertex labels
vertex_labels =[]
# initialize an empty list to store edge weights
edge_weights =[]
# create a set to store unique edge weights
unique_weights = set()
# get the order of sn3
order_of_sn3=(3* n)+1
# create a list of integers from 0 to k-1
labels = list(range(k))
# assign labels to vertices
for i in range(order_of_sn3):
vertex_labels.append(labels[i % k])
# assign weights to edges
for i in range(order_of_sn3):
# Ensure only adjacent vertices are connected
if i +1 order_of_sn3:
edge_weight = abs(vertex_labels[i]- vertex_labels[i +1])
if add_edge_to_graph(unique_weights, edge_weight):
edge_weights.append(edge_weight)
else:
# Adjust vertex labels if edge weight is not unique
vertex_labels[i]=(vertex_labels[i]+1)% k
vertex_labels[i +1]=(vertex_labels[i +1]+1)% k
edge_weights.append(edge_weight)
# return the vertex labels and edge weights
return vertex_labels, edge_weights
# Take input for n from the user
n = int(input("Enter the value of n: "))
k =((3* n)+1)//2 # calculate k based on n
vertex_labels, edge_weights = assign_labels(n, k)
print("vertex labels:", vertex_labels)
print("edge weights:", edge_weights)
Problem-1: Homogenous amalgamated Star : Sn,3
For n3, homogenous amalgamated
star Sn,3 admits the edge irregular k-
labeling.
Order of Sn,3=3n+1.
Vertex label is at most k and the edge
weights are distinctive, thus Sn,3 admits
the edge irregular k-labeling.
k=|~3n+12~|
Make changes to the above code so that the edge weights should be unique , and the output graph should look like the graph provided from the snapshot.
def add _ edge _ to _ graph ( unique _ weights,

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!