HEX
Server: Apache
System: Linux vps-cdc32557.vps.ovh.ca 5.15.0-156-generic #166-Ubuntu SMP Sat Aug 9 00:02:46 UTC 2025 x86_64
User: hanode (1017)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //lib/python3/dist-packages/networkx/algorithms/assortativity/tests/test_pairs.py
#!/usr/bin/env python
import networkx as nx
from .base_test import BaseTestAttributeMixing, BaseTestDegreeMixing


class TestAttributeMixingXY(BaseTestAttributeMixing):

    def test_node_attribute_xy_undirected(self):
        attrxy = sorted(nx.node_attribute_xy(self.G, 'fish'))
        attrxy_result = sorted([('one', 'one'),
                                ('one', 'one'),
                                ('two', 'two'),
                                ('two', 'two'),
                                ('one', 'red'),
                                ('red', 'one'),
                                ('blue', 'two'),
                                ('two', 'blue')
                                ])
        assert attrxy == attrxy_result

    def test_node_attribute_xy_undirected_nodes(self):
        attrxy = sorted(nx.node_attribute_xy(self.G, 'fish',
                                             nodes=['one', 'yellow']))
        attrxy_result = sorted([
        ])
        assert attrxy == attrxy_result

    def test_node_attribute_xy_directed(self):
        attrxy = sorted(nx.node_attribute_xy(self.D, 'fish'))
        attrxy_result = sorted([('one', 'one'),
                                ('two', 'two'),
                                ('one', 'red'),
                                ('two', 'blue')
                                ])
        assert attrxy == attrxy_result

    def test_node_attribute_xy_multigraph(self):
        attrxy = sorted(nx.node_attribute_xy(self.M, 'fish'))
        attrxy_result = [('one', 'one'),
                         ('one', 'one'),
                         ('one', 'one'),
                         ('one', 'one'),
                         ('two', 'two'),
                         ('two', 'two')
                         ]
        assert attrxy == attrxy_result

    def test_node_attribute_xy_selfloop(self):
        attrxy = sorted(nx.node_attribute_xy(self.S, 'fish'))
        attrxy_result = [('one', 'one'),
                         ('two', 'two')
                         ]
        assert attrxy == attrxy_result


class TestDegreeMixingXY(BaseTestDegreeMixing):

    def test_node_degree_xy_undirected(self):
        xy = sorted(nx.node_degree_xy(self.P4))
        xy_result = sorted([(1, 2),
                            (2, 1),
                            (2, 2),
                            (2, 2),
                            (1, 2),
                            (2, 1)])
        assert xy == xy_result

    def test_node_degree_xy_undirected_nodes(self):
        xy = sorted(nx.node_degree_xy(self.P4, nodes=[0, 1, -1]))
        xy_result = sorted([(1, 2),
                            (2, 1), ])
        assert xy == xy_result

    def test_node_degree_xy_directed(self):
        xy = sorted(nx.node_degree_xy(self.D))
        xy_result = sorted([(2, 1),
                            (2, 3),
                            (1, 3),
                            (1, 3)])
        assert xy == xy_result

    def test_node_degree_xy_multigraph(self):
        xy = sorted(nx.node_degree_xy(self.M))
        xy_result = sorted([(2, 3),
                            (2, 3),
                            (3, 2),
                            (3, 2),
                            (2, 3),
                            (3, 2),
                            (1, 2),
                            (2, 1)])
        assert xy == xy_result

    def test_node_degree_xy_selfloop(self):
        xy = sorted(nx.node_degree_xy(self.S))
        xy_result = sorted([(2, 2),
                            (2, 2)])
        assert xy == xy_result

    def test_node_degree_xy_weighted(self):
        G = nx.Graph()
        G.add_edge(1, 2, weight=7)
        G.add_edge(2, 3, weight=10)
        xy = sorted(nx.node_degree_xy(G, weight='weight'))
        xy_result = sorted([(7, 17),
                            (17, 10),
                            (17, 7),
                            (10, 17)])
        assert xy == xy_result