Uploaded by jagguvishu11

vishwas sn7

advertisement
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
Experiment-7
Student Name: Vishwas Srivastava
Branch: CSE
Semester: 5th
Subject Name: Social Network Lab
UID: 21BCS5056
Section/Group: 907-B
Date of Performance: 29/09/23
Subject Code: 21CSP-345
1.Aim: Create the resilience of the network by measuring the impact of node
removal or edge deletion on network connectivity and robustness byusing python.
2.Objective: The objective of this experiment is to measure the resilience of a
network by assessing the impact of node removal or edge deletion onnetwork
connectivity and robustness.
3.Requirement Analysis: Google Chrome, Online tools, Python IDE,
libraires(NetworkX).
4.Hardware Requirement: Computer/Laptop minimum 4GB,
Windows, Power Supply
5.Script and Output:
import networkx as nx
import matplotlib.pyplot as plt
print("21BCS5056")
# Create a graph representing the network
G = nx.Graph()
G.add_edges_from([(1, 2), (1, 3), (2, 3), (3, 4), (4,
5),(1,4),(2,4),(1,5),(3,5),(4,5)])
# Calculate the original network connectivity
original_connectivity = nx.node_connectivity(G)
# Remove a node from the network
G.remove_node(3)
# Calculate the updated network connectivity after node removal
updated_connectivity = nx.node_connectivity(G)
# Measure the impact on network connectivity
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
connectivity_impact = original_connectivity - updated_connectivity
# Measure the network robustness based on the number of disconnected
components
num_components = nx.number_connected_components(G)
nx.draw(G,with_labels=True)
plt.show()
# Print the results
print("Original Network Connectivity:", original_connectivity)
print("Updated Network Connectivity:", updated_connectivity)
print("Connectivity Impact:", connectivity_impact)
print("Number of Disconnected Components:", num_components)
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
6.Learning Outcomes:
The observations or outcome of this experiment will include:
• Measurements or metrics that quantify the impact of node removalor edge
deletion on network connectivity and robustness.
• Understood what is network resilience.
Download