I used it in a malware data science book, but I will leave it because it was different from when it was published and the explanation of the installation method was complicated. The environment is Linux Mint, Python 3.7 is already installed, and the environment was built using pipenv.
First, you'll need libgraphviz-dev and Python 3.7-dev to install. Also, pygraphviz is required, so you need to install it together.
sudo apt install libgraphviz-dev python3.7-dev
pipenv install networkx pygraphviz
I think that python3.7-dev needs to match the version of Python you are using. The code worked for the time being.
Since the usage of Networkx has changed a little, I will also describe it. The way to add node and edge attributes has changed.
network = networkx.Graph()
#Add node and set attributes
network.add_node(1)
network.add_node(2)
network.nodes[1]['attribute'] = 'value'
#Add edge and set attributes
network.add_edge(1, 2)
network[1][2]['attribute'] = 'value'
There should be no problem with the above method.
Recommended Posts