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:
You can register an environment like so:
With a session inside a particular environment in place we can interactively fetch data:
Within a Wolfram notebook you can type ’>’ and run all you wish:
In[19]:=
import networkx as nx
nx.__version__
If you have a NetworkX pickle you can fetch it and hand it over to Wolfram:
Creating the graph is now as simple as:
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).