Importing NetworkX into Wolfram

Once in a while it can be useful to fetch external graphs into the Wolfram stack for analysis or conversely.
Below is a simple procedure to do so.

First, you need to make sure that Python can be accessed:

nx22_1.png

nx22_2.png

You can register an environment like so:

nx22_3.png

nx22_4.png

With a session inside a particular environment in place we can interactively fetch data:

nx22_5.png

nx22_6.gif

Within a Wolfram notebook you can type ’>’  and run all you wish:

In[19]:=

import networkx as nx
nx.__version__

nx22_7.png

If you have a NetworkX pickle you can fetch it and hand it over to Wolfram:

nx22_8.png

Creating the graph is now as simple as:

nx22_9.png

nx22_10.gif

This is not particularly pretty of course but that’s not Wolfram’s strength. If you wish to see beautiful renderings, use yEd or yEd Live (explained elsewhere on this site).

Created with the Wolfram Language