2
from nose.tools import assert_equal, assert_raises, assert_not_equal,assert_true
4
from networkx.readwrite.json_graph import *
10
H = node_link_graph(node_link_data(G))
13
def test_graph_attributes(self):
15
G.add_node(1,color='red')
16
G.add_edge(1,2,width=7)
20
H = node_link_graph(node_link_data(G))
21
assert_equal(H.graph['foo'],'bar')
22
assert_equal(H.node[1]['color'],'red')
23
assert_equal(H[1][2]['width'],7)
25
d=json.dumps(node_link_data(G))
26
H = node_link_graph(json.loads(d))
27
assert_equal(H.graph['foo'],'bar')
28
assert_equal(H.graph[1],'one')
29
assert_equal(H.node[1]['color'],'red')
30
assert_equal(H[1][2]['width'],7)
32
def test_digraph(self):
34
H = node_link_graph(node_link_data(G))
35
assert_true(H.is_directed())
37
def test_multidigraph(self):
39
H = node_link_graph(node_link_data(G))
40
assert_true(H.is_directed())
41
assert_true(H.is_multigraph())