Converting network data into networks
It is time to take our created network data and create two graphs, one for Alice’s Adventures in Wonderland, and another for The Metamorphosis. We aren’t going to dive deep into network analysis yet, as that is for later chapters. But let’s see how they look and see what insights emerge.
First, we need to import the NetworkX library, and then we need to create our graphs. This is extremely easy to do because we have created Pandas DataFrames, which NetworkX will use. This is the easiest way I have found of creating graphs.
First, if you haven’t done so yet, you need to install NetworkX. You can do so with the following command:
pip install networkx
Now that we have installed NetworkX, let’s create our two networks:
import networkx as nx G_alice = nx.from_pandas_edgelist(alice_network_df) G_morph = nx.from_pandas_edgelist(morph_network_df)
It’s that easy. We have already done the difficult...