## Mercurial > repos > shellac > sam_consensus_v3

### view env/lib/python3.9/site-packages/networkx/algorithms/tests/test_swap.py @ 0:4f3585e2f14b draft default tip

Find changesets by keywords (author, files, the commit message), revision
number or hash, or revset expression.

"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"

author | shellac |
---|---|

date | Mon, 22 Mar 2021 18:12:50 +0000 |

parents | |

children |

line wrap: on

line source

import pytest import networkx as nx # import random # random.seed(0) def test_double_edge_swap(): graph = nx.barabasi_albert_graph(200, 1) degrees = sorted(d for n, d in graph.degree()) G = nx.double_edge_swap(graph, 40) assert degrees == sorted(d for n, d in graph.degree()) def test_double_edge_swap_seed(): graph = nx.barabasi_albert_graph(200, 1) degrees = sorted(d for n, d in graph.degree()) G = nx.double_edge_swap(graph, 40, seed=1) assert degrees == sorted(d for n, d in graph.degree()) def test_connected_double_edge_swap(): graph = nx.barabasi_albert_graph(200, 1) degrees = sorted(d for n, d in graph.degree()) G = nx.connected_double_edge_swap(graph, 40, seed=1) assert nx.is_connected(graph) assert degrees == sorted(d for n, d in graph.degree()) def test_double_edge_swap_small(): with pytest.raises(nx.NetworkXError): G = nx.double_edge_swap(nx.path_graph(3)) def test_double_edge_swap_tries(): with pytest.raises(nx.NetworkXError): G = nx.double_edge_swap(nx.path_graph(10), nswap=1, max_tries=0) def test_connected_double_edge_swap_small(): with pytest.raises(nx.NetworkXError): G = nx.connected_double_edge_swap(nx.path_graph(3)) def test_connected_double_edge_swap_not_connected(): with pytest.raises(nx.NetworkXError): G = nx.path_graph(3) nx.add_path(G, [10, 11, 12]) G = nx.connected_double_edge_swap(G) def test_degree_seq_c4(): G = nx.cycle_graph(4) degrees = sorted(d for n, d in G.degree()) G = nx.double_edge_swap(G, 1, 100) assert degrees == sorted(d for n, d in G.degree())