A Tutorial on NetworkX: Network Analysis in Python (Part-I)

Dr. Soumen Atta, Ph.D.
The Startup
Published in
6 min readJan 31, 2021

--

In this tutorial, we will learn about the NetworkX package of Python. NetworkX stands for network analysis in Python. It is mainly used for creating, manipulating, and study complex graphs. This is the Part-I of the tutorial on NetworkX. The remaining tutorial will be posted in different parts.

Prerequisites: Basic knowledge about graph theory and Python programming.

“NetworkX is a Python package for the creation, manipulation, and study of the structure, dynamics, and functions of complex networks.” — https://networkx.org/

Installation

If the NetworkX package is not installed in your system, you have to install it at first. You can use the following command to install it.

pip install networkx

The above command will install the NetworkX package in your system. Now, you are ready to use it. Sometimes, the above command may issue an error message. In that case, you are advised to use pip3 command instead of pip. It depends on how your system is configured.

Importing

You can use the ‘networkx’ module by importing it using the following command:

import networkx as nx

--

--

Dr. Soumen Atta, Ph.D.
The Startup

Assistant Professor, Center for Information Technologies and Applied Mathematics, School of Engineering and Management, University of Nova Gorica, Slovenia