~ubuntu-branches/ubuntu/utopic/python-networkx/utopic

« back to all changes in this revision

Viewing changes to networkx/readwrite/json_graph/tests/test_tree.py

  • Committer: Package Import Robot
  • Author(s): Sandro Tosi
  • Date: 2012-08-11 12:41:30 UTC
  • mfrom: (1.4.1) (5.1.13 sid)
  • Revision ID: package-import@ubuntu.com-20120811124130-whr6uso7fncyg8bi
Tags: 1.7-1
* New upstream release
* debian/patches/changeset_*
  - removed, included upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import json
 
2
from nose.tools import assert_equal, assert_raises, assert_not_equal,assert_true
 
3
import networkx as nx
 
4
from networkx.readwrite.json_graph import *
 
5
 
 
6
class TestTree:
 
7
 
 
8
    def test_graph(self):
 
9
        G=nx.DiGraph()
 
10
        G.add_nodes_from([1,2,3],color='red')
 
11
        G.add_edge(1,2,foo=7)
 
12
        G.add_edge(1,3,foo=10)
 
13
        G.add_edge(3,4,foo=10)
 
14
        H = tree_graph(tree_data(G,1))
 
15
        nx.is_isomorphic(G,H)
 
16
 
 
17
    def test_graph_attributes(self):
 
18
        G=nx.DiGraph()
 
19
        G.add_nodes_from([1,2,3],color='red')
 
20
        G.add_edge(1,2,foo=7)
 
21
        G.add_edge(1,3,foo=10)
 
22
        G.add_edge(3,4,foo=10)
 
23
        H = tree_graph(tree_data(G,1))
 
24
        assert_equal(H.node[1]['color'],'red')
 
25
 
 
26
        d = json.dumps(tree_data(G,1))
 
27
        H = tree_graph(json.loads(d))
 
28
        assert_equal(H.node[1]['color'],'red')
 
29