Network Data Representations
Explore different methods to represent complex networks such as edge lists, adjacency matrices, and adjacency lists using Python's NetworkX library. Understand when and how to apply each representation to optimize computational resources and prepare networks for analysis.
We'll cover the following...
Representing complex networks
In this lesson, we’re going to explore different ways we can represent a complex network and how we can implement them in the NetworkX library. The importance of knowing these different types of representations is to know when to use each to be more productive and waste less computational resources. In some cases, some algorithms are applied more easily to one form over another, so converting between these forms will be very useful for our practice as a complex network analyst.
For every method, we’re going to see how to represent the following network:
Edge lists
The first way of representing complex networks is the edge list.
In an edge list, we have a list of tuples that defines which edges exist in our complex network.
To make the reference network for this lesson, we can easily do the following:
By using the edge list, we can’t represent a case where we have a node without any edge connected to it, which we call a singleton. The data itself will never contain it because there’s no edge to represent. One way we can overcome this in NetworkX is to define the list of nodes separately:
Line 16: It adds the list of nodes to the graph and the output of the
G.nodes()method returns the new node, even if it has no edge.
Exercise
Look at the following network: