John Locke - 1 year ago 134
Python Question

Plotting in numpy a graph using the two lowest eigenvalues and eigenvectors

How do I use the eigenvectors corresponding to the two lowest eigenvalues (different from 0) as the x,y coordinates to plot the graph?

I have arrays of eigenvalues and eigenvectors from the laplacian of a graph of nodes. I want to do something similar to the following link that is in MATLAB, but in Python. Also, instead of just the Fielder vector, I also want the next vector larger than the Fielder as well:

https://www.mathworks.com/examples/matlab/mw/matlab-ex64540792-partition-graph-with-laplacian-matrix

This answer assumes you've already got nodes in a list `nodelist` and two vectors `vec1` and `vec2` which are in the same order.

Networkx uses a dict (usually called `pos`) for which `pos[u]` is the (x,y) coordinates of the node `u`.

``````import networkx as nx

#your code here to define network and find the vectors.
#Please edit a simple version of this code into your question so I can
In defining `pos`, I've used a dict comprehension and zip.