Example #1
0
    def test_missing_edges(self):
        """A tournament must not have any pair of nodes without at least
        one edge joining the pair.

        """
        G = DiGraph()
        G.add_edges_from([(0, 1), (1, 2), (2, 3), (3, 0), (1, 3)])
        assert_false(is_tournament(G))
Example #2
0
    def test_missing_edges(self):
        """A tournament must not have any pair of nodes without at least
        one edge joining the pair.

        """
        G = DiGraph()
        G.add_edges_from([(0, 1), (1, 2), (2, 3), (3, 0), (1, 3)])
        assert not is_tournament(G)
Example #3
0
    def test_bidirectional_edges(self):
        """A tournament must not have any pair of nodes with greater
        than one edge joining the pair.

        """
        G = DiGraph()
        G.add_edges_from([(0, 1), (1, 2), (2, 3), (3, 0), (1, 3), (0, 2)])
        G.add_edge(1, 0)
        assert not is_tournament(G)
Example #4
0
    def test_bidirectional_edges(self):
        """A tournament must not have any pair of nodes with greater
        than one edge joining the pair.

        """
        G = DiGraph()
        G.add_edges_from([(0, 1), (1, 2), (2, 3), (3, 0), (1, 3), (0, 2)])
        G.add_edge(1, 0)
        assert_false(is_tournament(G))
Example #5
0
 def test_graph_is_tournament_seed(self):
     for n in range(10):
         G = random_tournament(5, seed=1)
         assert is_tournament(G)
Example #6
0
 def test_graph_is_tournament(self):
     for n in range(10):
         G = random_tournament(5)
         assert is_tournament(G)
Example #7
0
 def test_self_loops(self):
     """A tournament must have no self-loops."""
     G = DiGraph()
     G.add_edges_from([(0, 1), (1, 2), (2, 3), (3, 0), (1, 3), (0, 2)])
     G.add_edge(0, 0)
     assert not is_tournament(G)
Example #8
0
 def test_is_tournament(self):
     G = DiGraph()
     G.add_edges_from([(0, 1), (1, 2), (2, 3), (3, 0), (1, 3), (0, 2)])
     assert is_tournament(G)
Example #9
0
 def test_graph_is_tournament(self):
     for n in range(10):
         G = random_tournament(5)
         assert_true(is_tournament(G))
Example #10
0
 def test_self_loops(self):
     """A tournament must have no self-loops."""
     G = DiGraph()
     G.add_edges_from([(0, 1), (1, 2), (2, 3), (3, 0), (1, 3), (0, 2)])
     G.add_edge(0, 0)
     assert_false(is_tournament(G))
Example #11
0
 def test_is_tournament(self):
     G = DiGraph()
     G.add_edges_from([(0, 1), (1, 2), (2, 3), (3, 0), (1, 3), (0, 2)])
     assert_true(is_tournament(G))
Example #12
0
import networkx as nx
from networkx.algorithms import tournament
import numpy as np
import matplotlib.pyplot as plt
import pylab

G = nx.DiGraph()

# ajouter les arcs ici
G.add_edges_from([(1, 2)], weight=4)
G.add_edges_from([(0, 2)], weight=5)
G.add_edges_from([(0, 0)], weight=0)

print(tournament.is_tournament(G))

edge_labels = dict([((
    u,
    v,
), d['weight']) for u, v, d in G.edges(data=True)])

pos = nx.circular_layout(G)

nx.draw_networkx_edge_labels(G, pos, edge_labels=edge_labels)
nx.draw_networkx(G, pos, node_size=200)
pylab.show()
Example #13
0
def test_graph_is_tournament_zero_node():
    G = random_tournament(0)
    assert is_tournament(G)
Example #14
0
def test_graph_is_tournament_one_node():
    G = random_tournament(1)
    assert is_tournament(G)