In [1]:
%matplotlib inline
In [2]:
import networkx as nx
import numpy as np
t1 = np.array([[1,3,1,1],[3,1,1,1],[1,1,1,1],[1,1,1,1]])
g = nx.to_networkx_graph(t1)
In [3]:
nx.draw(g)
In [4]:
t1
Out[4]:
In [5]:
g.add_node(4)
g.add_edge(1,4)
In [6]:
nx.draw(g)
In [7]:
m1 = nx.to_numpy_matrix(g)
print m1
In [8]:
g.remove_node(3)
In [9]:
nx.draw(g)
In [10]:
nx.to_numpy_matrix(g)
Out[10]:
In [11]:
m2 = nx.to_numpy_matrix(g)
In [12]:
print m2
In [14]:
import networkx.generators as nxg
In [30]:
nx.draw(nxg.random_lobster(20, 0.2, 0.3))
In [32]:
h1 = nx.star_graph(4)
nx.draw(h1)
In [34]:
h1m = nx.to_numpy_matrix(h1)
In [35]:
h1m[1,2] = 3
In [39]:
h2 = nx.from_numpy_matrix(h1m)
In [40]:
nx.draw(h2)
In [38]:
h1m[1,2] = 0
In [ ]: