A NetworkX project begins with importing module networkx (usually under the name nx).
|||import networkx as nx|
A NetworkX network is a collection of edges and labeled nodes. The library allows you to use any hashable Python data as a node label (different labels within the same graph may belong to different data types). To create a new network graph, you must choose an appropriate graph type and call the respective constructor; pass either no parameters (for an empty graph) or a list of edges as node pairs (lists or tuples). NetworkX supports four graph types:
Undirected graphs consist only of undirected edges—edges that can be traversed in either direction so that an edge from ...