Example 2: Network analysis using NetworkX librarypython import networkx as nx # Creating a graph object G = nx.Graph() # Adding nodes and edges G.add_edge("A", "B") G.add_edge("B", "C") G.add_edge("B", "D") # Computing network attributes print("Degree of node B:", G.degree("B")) print("Diameter of the network:", nx.diameter(G)) print("Clustering coefficient of node B:", nx.clustering(G, "B")) ``` These examples demonstrate the use of the NetworkX library for creating, manipulating, and analyzing graphs. The library is widely used in different fields such as social network analysis, transportation network analysis, biological network analysis, etc.