python networkx code example Example 1: install networkx python pip install networkx Example 2: networkx >>> import networkx as nx >>> G = nx.Graph()