NPTEL Social Networks Week 1 Assignment Answers 2025
1. Which Python code correctly computes the sum of even numbers in the list L = [3, 5, 8, 2, 6] ?
- sum([x for x in L if x % 2 == 0])
- sum([x for x in L if x % 2 != 0])
- sum([x for x in L if x > 2])
- sum(L)
Answer :- For Answer Click Here
2. You are given a dictionary d = {‘A’: 10, ‘B’: 20, ‘C’: 30} . Which Python code snippet correctly adds a new key D with value 40 to the dictionary?
- d[‘D’] = 40
- d.add(‘D’, 40)
- d.update(‘D’, 40)
- d.append({‘D’: 40})
Answer :-
3. Given the following Python code snippet, what will be the output?
import matplotlib.pyplot as plt
x = [1, 2, 3, 4]
y = [1, 4, 9, 16]
plt.plot(x, y)
plt.show()
- A bar chart displaying the values in x and y .
- A line graph connecting the points (1,1), (2,4), (3,9), (4,16) .
- A scatter plot with points (1,1), (2,4), (3,9), (4,16) .
- A histogram displaying the values of x and y .
Answer :-
4. Using the NetworkX library, how would you create an undirected graph with three nodes ( A , B , C ) and two edges ( A-B and B-C )?
- G = nx.Graph()
G.add_edges_from([(‘A’, ‘B’), (‘B’, ‘C’)]) - G = nx.DiGraph()
G.add_edges_from([(‘A’, ‘B’), (‘B’, ‘C’)]) - G = nx.Graph()
G.add_nodes_from([‘A’, ‘B’, ‘C’]) - G = nx.Graph()
G.add_edges_from([(‘A’, ‘B’), (‘B’, ‘C’)], directed=True)
Answer :-
5. In the PageRank algorithm, what is the primary assumption regarding the link structure of the web?
- Pages that are linked to more often are likely more important.
- Pages that are less frequently linked are likely more important.
- Pages with more content are likely more important.
- Pages without links are considered equally important as those with links.
Answer :-
6. In a social network, you are tasked with finding the shortest path between two individuals, A and B . Which of the following algorithms would be most suitable?
- Dijkstra’s Algorithm
- A* Search Algorithm
- Breadth-First Search (BFS)
- Depth-First Search (DFS)
Answer :- For Answer Click Here
7. Which of the following methods is commonly used for link prediction in a social network?
- Collaborative Filtering
- K-means Clustering
- Matrix Factorization
- Jaccard Similarity Index
Answer :-
8. In models of contagion in social networks, what does the term “threshold” specifically refer to?
- The minimum number of links required to spread an infection in a network.
- The fraction of neighbors a node needs to be influenced by to adopt a new behavior.
- The time it takes for an infection to spread from one node to another.
- The maximum number of nodes that can be infected at any given time.
Answer :-
9. Which centrality measure would you use to find the individuals who have the shortest average path length to all other nodes in the network?
- Degree Centrality
- Closeness Centrality
- Betweenness Centrality
- Eigenvector Centrality
Answer :-
10. Which of the following NetworkX functions can be used to predict potential links in a network based on node similarity indices?
- nx.resource_allocation_index(G)
- nx.shortest_path_length(G)
- nx.closeness_centrality(G)
- nx.betweenness_centrality(G)
Answer :- For Answer Click Here
NPTEL Social Networks Week 2 Assignment Answers 2025
1. A graph has a diameter of 1. Which of the following statements must be true?
- The graph is a complete graph.
- All nodes in the graph are directly connected to every other node.
- The graph contains the maximum possible number of edges for its number of nodes.
- The graph is sparse with relatively fewer edges compared to nodes.
- Adding or removing an edge cannot change its diameter.
Answer :- For Answers Click Here
2. In the Web Graph model, what do the nodes and edges represent?
- Nodes are web pages, and edges are hyperlinks between them.
- Nodes are servers, and edges are data transfer rates.
- Nodes are users, and edges are user interactions.
- Nodes are hashtags, and edges are co-occurrence frequencies.
Answer :-
3. A dataset represents a multigraph (a graph where multiple edges are allowed between two nodes). Which method in NetworkX allows you to load such a graph from an edge list file?
- read_multiedgelist()
- read_edgelist() with create_using=nx.MultiGraph()
- read_gml()
- read_multigraph()
Answer :-
4. Consider the following GML representation of a directed graph:

Which of the following correctly interprets the structure and properties of the graph described by the GML code?
- The graph is undirected, with two nodes labeled “A” and “B” connected by two edges with weights 5 and 3, respectively.
- The graph is directed, with node “A” pointing to node “B” with a weight of 5, and node “B” pointing back to node “A” with a weight of 3.
- The graph is directed, with node “A” pointing to node “B” with a weight of 3, and node “B” pointing to node “A” with a weight of 5.
- The graph is directed and contains a self-loop at node “A” with a weight of 5, and another self-loop at node “B” with a weight of 3.
Answer :-
5. Consider the following characteristics of different social network dataset formats. Which of the following statements is true about these formats?
- Adjacency Matrix is most efficient for storing sparse graphs because it requires minimal space for large graphs with few edges.
- Edge List format is not ideal for storing sparse graphs as it does not require extra space to store non-existing edges between nodes.
- Adjacency List is space-efficient for sparse graphs and allows for fast traversal of neighbors, making it suitable for networks with relatively few edges compared to nodes.
- Gephi File format is designed for large-scale networks and is not ideal for visualizing or analyzing graphs with edge weights or node attributes.
Answer :-
6. Pajek datasets are usually available in which of the following format?
- .csv
- .net
- .txt
- .tar
Answer :- For Answers Click Here
7. Which NetworkX function would you use to visualize the degree distribution of a graph?
- nx.degree_histogram(G)
- nx.closeness_centrality(G)
- nx.shortest_path_length(G)
- nx.eigenvector_centrality(G)
Answer :-
8. In Gephi, which metric would you compute to determine the connectivity between communities in a graph?
- Modularity
- Degree centrality
- Closeness centrality
- Betweenness centrality
Answer :-
9. In the context of graph theory, what is the critical threshold for the emergence of a giant connected component in a random graph?
- When the number of edges equals the number of nodes.
- When the average degree is 1.
- When the clustering coefficient reaches 1.
- When the network diameter becomes constant.
Answer :-
10. In a random graph G(n,p), when does a giant connected component typically emerge?
- When the edge probability p is very small.
- When the edge probability p is large enough to connect most nodes.
- When the number of nodes n is very large.
- When the graph has no isolated nodes.
Answer :- For Answers Click Here