Ask Your Question

NetworkX - create a Graph

asked 2013-09-05 13:11:59 -0500

mresimulator gravatar image

updated 2016-06-07 13:58:59 -0500

FrédéricC gravatar image

Hi experts!

I wanna use


where G is the graph associated to de adjacency matrix M (a N x N numpy array) of a undirected graph.

How can I create a networkx graph (necesary for use networkx.has_path()) from M?

Thanks a lot!

edit retag flag offensive close merge delete



You should probably use Sage objects directly (i.e. a `matrix` instead of a numpy array, and a `Graph` instead of a NetworkX object), since there are better interfaced to eachother, and you will not have to rewrite everything.

tmonteil gravatar imagetmonteil ( 2013-09-06 03:43:44 -0500 )edit

For the record, a Sage graph has a method that returns the corresponding NetworkX graph.

Hugh Thomas gravatar imageHugh Thomas ( 2017-09-18 16:28:47 -0500 )edit

1 answer

Sort by » oldest newest most voted

answered 2013-09-06 09:03:31 -0500

mresimulator gravatar image

A networkx graph is necesary for use networkx.has_path().

So, how can I generate this networkx graph from a python matrix or numpy matrix?


edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2013-09-05 13:11:59 -0500

Seen: 172 times

Last updated: Sep 06 '13