Esempio n. 1
0
    def test_threshold_sequence_graph_test(self):
        G=nx.star_graph(10)
        assert_true(nxt.is_threshold_graph(G))
        assert_true(nxt.is_threshold_sequence(list(d for n, d in G.degree())))

        G=nx.complete_graph(10)
        assert_true(nxt.is_threshold_graph(G))
        assert_true(nxt.is_threshold_sequence(list(d for n, d in G.degree())))

        deg=[3,2,2,1,1,1]
        assert_false(nxt.is_threshold_sequence(deg))

        deg=[3,2,2,1]
        assert_true(nxt.is_threshold_sequence(deg))

        G=nx.generators.havel_hakimi_graph(deg)
        assert_true(nxt.is_threshold_graph(G))
Esempio n. 2
0
    def test_threshold_sequence_graph_test(self):
        G = nx.star_graph(10)
        assert nxt.is_threshold_graph(G)
        assert nxt.is_threshold_sequence(list(d for n, d in G.degree()))

        G = nx.complete_graph(10)
        assert nxt.is_threshold_graph(G)
        assert nxt.is_threshold_sequence(list(d for n, d in G.degree()))

        deg = [3, 2, 2, 1, 1, 1]
        assert not nxt.is_threshold_sequence(deg)

        deg = [3, 2, 2, 1]
        assert nxt.is_threshold_sequence(deg)

        G = nx.generators.havel_hakimi_graph(deg)
        assert nxt.is_threshold_graph(G)
Esempio n. 3
0
    def test_finding_routines(self):
        G=nx.Graph({1:[2],2:[3],3:[4],4:[5],5:[6]})
        G.add_edge(2,4)
        G.add_edge(2,5)
        G.add_edge(2,7)
        G.add_edge(3,6)
        G.add_edge(4,6)

        # Alternating 4 cycle
        assert_equal(nxt.find_alternating_4_cycle(G), [1, 2, 3, 6])

        # Threshold graph
        TG=nxt.find_threshold_graph(G)
        assert_true(nxt.is_threshold_graph(TG))
        assert_equal(sorted(TG.nodes()), [1, 2, 3, 4, 5, 7])

        cs=nxt.creation_sequence(dict(TG.degree()), with_labels=True)
        assert_equal(nxt.find_creation_sequence(G), cs)
Esempio n. 4
0
    def test_finding_routines(self):
        G = nx.Graph({1: [2], 2: [3], 3: [4], 4: [5], 5: [6]})
        G.add_edge(2, 4)
        G.add_edge(2, 5)
        G.add_edge(2, 7)
        G.add_edge(3, 6)
        G.add_edge(4, 6)

        # Alternating 4 cycle
        assert nxt.find_alternating_4_cycle(G) == [1, 2, 3, 6]

        # Threshold graph
        TG = nxt.find_threshold_graph(G)
        assert nxt.is_threshold_graph(TG)
        assert sorted(TG.nodes()) == [1, 2, 3, 4, 5, 7]

        cs = nxt.creation_sequence(dict(TG.degree()), with_labels=True)
        assert nxt.find_creation_sequence(G) == cs