Statistics
| Branch: | Revision:

iof-tools / networkxMiCe / networkx-master / networkx / classes / tests / test_ordered.py @ 5cef0f13

History | View | Annotate | Download (1.22 KB)

1
from nose.tools import assert_equals
2
import networkx as nx
3

    
4

    
5
class SmokeTestOrdered(object):
6
    # Just test instantiation.
7
    def test_graph(self):
8
        G = nx.OrderedGraph()
9

    
10
    def test_digraph(self):
11
        G = nx.OrderedDiGraph()
12

    
13
    def test_multigraph(self):
14
        G = nx.OrderedMultiGraph()
15

    
16
    def test_multidigraph(self):
17
        G = nx.OrderedMultiDiGraph()
18

    
19

    
20
class TestOrderedFeatures(object):
21
    def setUp(self):
22
        self.G = nx.OrderedDiGraph()
23
        self.G.add_nodes_from([1, 2, 3])
24
        self.G.add_edges_from([(2, 3), (1, 3)])
25

    
26
    def test_subgraph_order(self):
27
        G = self.G
28
        G_sub = G.subgraph([1, 2, 3])
29
        assert_equals(list(G.nodes), list(G_sub.nodes))
30
        assert_equals(list(G.edges), list(G_sub.edges))
31
        assert_equals(list(G.pred[3]), list(G_sub.pred[3]))
32
        assert_equals([2, 1], list(G_sub.pred[3]))
33
        assert_equals([], list(G_sub.succ[3]))
34

    
35
        G_sub = nx.induced_subgraph(G, [1, 2, 3])
36
        assert_equals(list(G.nodes), list(G_sub.nodes))
37
        assert_equals(list(G.edges), list(G_sub.edges))
38
        assert_equals(list(G.pred[3]), list(G_sub.pred[3]))
39
        assert_equals([2, 1], list(G_sub.pred[3]))
40
        assert_equals([], list(G_sub.succ[3]))