<s> """<STR_LIT>""" <EOL> import itertools <EOL> from nose . tools import * <EOL> import networkx as nx <EOL> from networkx import * <EOL> from networkx . algorithms . isomorphism . isomorph import graph_could_be_isomorphic <EOL> from networkx . testing import assert_edges_equal <EOL> from networkx . testing import assert_nodes_equal <EOL> is_isomorphic = graph_could_be_isomorphic <EOL> class TestGeneratorClassic ( ) : <EOL> def test_balanced_tree ( self ) : <EOL> for r , h in [ ( <NUM_LIT:2> , <NUM_LIT:2> ) , ( <NUM_LIT:3> , <NUM_LIT:3> ) , ( <NUM_LIT:6> , <NUM_LIT:2> ) ] : <EOL> t = balanced_tree ( r , h ) <EOL> order = t . order ( ) <EOL> assert_true ( order == ( r ** ( h + <NUM_LIT:1> ) - <NUM_LIT:1> ) / ( r - <NUM_LIT:1> ) ) <EOL> assert_true ( is_connected ( t ) ) <EOL> assert_true ( t . size ( ) == order - <NUM_LIT:1> ) <EOL> dh = degree_histogram ( t ) <EOL> assert_equal ( dh [ <NUM_LIT:0> ] , <NUM_LIT:0> ) <EOL> assert_equal ( dh [ <NUM_LIT:1> ] , r ** h ) <EOL> assert_equal ( dh [ r ] , <NUM_LIT:1> ) <EOL> assert_equal ( dh [ r + <NUM_LIT:1> ] , order - r ** h - <NUM_LIT:1> ) <EOL> assert_equal ( len ( dh ) , r + <NUM_LIT:2> ) <EOL> def test_balanced_tree_star ( self ) : <EOL> t = balanced_tree ( r = <NUM_LIT:2> , h = <NUM_LIT:1> ) <EOL> assert_true ( is_isomorphic ( t , star_graph ( <NUM_LIT:2> ) ) ) <EOL> t = balanced_tree ( r = <NUM_LIT:5> , h = <NUM_LIT:1> ) <EOL> assert_true ( is_isomorphic ( t , star_graph ( <NUM_LIT:5> ) ) ) <EOL> t = balanced_tree ( r = <NUM_LIT:10> , h = <NUM_LIT:1> ) <EOL> assert_true ( is_isomorphic ( t , star_graph ( <NUM_LIT:10> ) ) ) <EOL> def test_balanced_tree_path ( self ) : <EOL> """<STR_LIT>""" <EOL> T = balanced_tree ( <NUM_LIT:1> , <NUM_LIT:4> ) <EOL> P = path_graph ( <NUM_LIT:5> ) <EOL> assert_true ( is_isomorphic ( T , P ) ) <EOL> def test_full_rary_tree ( self ) : <EOL> r = <NUM_LIT:2> <EOL> n = <NUM_LIT:9> <EOL> t = full_rary_tree ( r , n ) <EOL> assert_equal ( t . order ( ) , n ) <EOL> assert_true ( is_connected ( t ) ) <EOL> dh = degree_histogram ( t ) <EOL> assert_equal ( dh [ <NUM_LIT:0> ] , <NUM_LIT:0> ) <EOL> assert_equal ( dh [ <NUM_LIT:1> ] , <NUM_LIT:5> ) <EOL> assert_equal ( dh [ r ] , <NUM_LIT:1> ) <EOL> assert_equal ( dh [ r + <NUM_LIT:1> ] , <NUM_LIT:9> - <NUM_LIT:5> - <NUM_LIT:1> ) <EOL> assert_equal ( len ( dh ) , r + <NUM_LIT:2> ) <EOL> def test_full_rary_tree_balanced ( self ) : <EOL> t = full_rary_tree ( <NUM_LIT:2> , <NUM_LIT:15> ) <EOL> th = balanced_tree ( <NUM_LIT:2> , <NUM_LIT:3> ) <EOL> assert_true ( is_isomorphic ( t , th ) ) <EOL> def test_full_rary_tree_path ( self ) : <EOL> t = full_rary_tree ( <NUM_LIT:1> , <NUM_LIT:10> ) <EOL> assert_true ( is_isomorphic ( t , path_graph ( <NUM_LIT:10> ) ) ) <EOL> def test_full_rary_tree_empty ( self ) : <EOL> t = full_rary_tree ( <NUM_LIT:0> , <NUM_LIT:10> ) <EOL> assert_true ( is_isomorphic ( t , empty_graph ( <NUM_LIT:10> ) ) ) <EOL> t = full_rary_tree ( <NUM_LIT:3> , <NUM_LIT:0> ) <EOL> assert_true ( is_isomorphic ( t , empty_graph ( <NUM_LIT:0> ) ) ) <EOL> def test_full_rary_tree_3_20 ( self ) : <EOL> t = full_rary_tree ( <NUM_LIT:3> , <NUM_LIT:20> ) <EOL> assert_equal ( t . order ( ) , <NUM_LIT:20> ) <EOL> def test_barbell_graph ( self ) : <EOL> m1 = <NUM_LIT:3> ; m2 = <NUM_LIT:5> <EOL> b = barbell_graph ( m1 , m2 ) <EOL> assert_true ( number_of_nodes ( b ) == <NUM_LIT:2> * m1 + m2 ) <EOL> assert_true ( number_of_edges ( b ) == m1 * ( m1 - <NUM_LIT:1> ) + m2 + <NUM_LIT:1> ) <EOL> assert_equal ( b . name , '<STR_LIT>' ) <EOL> m1 = <NUM_LIT:4> ; m2 = <NUM_LIT:10> <EOL> b = barbell_graph ( m1 , m2 ) <EOL> assert_true ( number_of_nodes ( b ) == <NUM_LIT:2> * m1 + m2 ) <EOL> assert_true ( number_of_edges ( b ) == m1 * ( m1 - <NUM_LIT:1> ) + m2 + <NUM_LIT:1> ) <EOL> assert_equal ( b . name , '<STR_LIT>' ) <EOL> m1 = <NUM_LIT:3> ; m2 = <NUM_LIT:20> <EOL> b = barbell_graph ( m1 , m2 ) <EOL> assert_true ( number_of_nodes ( b ) == <NUM_LIT:2> * m1 + m2 ) <EOL> assert_true ( number_of_edges ( b ) == m1 * ( m1 - <NUM_LIT:1> ) + m2 + <NUM_LIT:1> ) <EOL> assert_equal ( b . name , '<STR_LIT>' ) <EOL> m1 = <NUM_LIT:1> ; m2 = <NUM_LIT:20> <EOL> assert_raises ( networkx . exception . NetworkXError , barbell_graph , m1 , m2 ) <EOL> m1 = <NUM_LIT:5> ; m2 = - <NUM_LIT:2> <EOL> assert_raises ( networkx . exception . NetworkXError , barbell_graph , m1 , m2 ) <EOL> m1 = <NUM_LIT:2> ; m2 = <NUM_LIT:5> <EOL> b = barbell_graph ( m1 , m2 ) <EOL> assert_true ( is_isomorphic ( b , path_graph ( m2 + <NUM_LIT:4> ) ) ) <EOL> m1 = <NUM_LIT:2> ; m2 = <NUM_LIT:10> <EOL> b = barbell_graph ( m1 , m2 ) <EOL> assert_true ( is_isomorphic ( b , path_graph ( m2 + <NUM_LIT:4> ) ) ) <EOL> m1 = <NUM_LIT:2> ; m2 = <NUM_LIT:20> <EOL> b = barbell_graph ( m1 , m2 ) <EOL> assert_true ( is_isomorphic ( b , path_graph ( m2 + <NUM_LIT:4> ) ) ) <EOL> assert_raises ( networkx . exception . NetworkXError , barbell_graph , m1 , m2 , <EOL> create_using = DiGraph ( ) ) <EOL> mb = barbell_graph ( m1 , m2 , create_using = MultiGraph ( ) ) <EOL> assert_equal ( sorted ( mb . edges ( ) ) , sorted ( b . edges ( ) ) ) <EOL> def test_complete_graph ( self ) : <EOL> for m in [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:5> ] : <EOL> g = complete_graph ( m ) <EOL> assert_true ( number_of_nodes ( g ) == m ) <EOL> assert_true ( number_of_edges ( g ) == m * ( m - <NUM_LIT:1> ) // <NUM_LIT:2> ) <EOL> mg = complete_graph ( m , create_using = MultiGraph ( ) ) <EOL> assert_equal ( sorted ( mg . edges ( ) ) , sorted ( g . edges ( ) ) ) <EOL> g = complete_graph ( "<STR_LIT:abc>" ) <EOL> assert_equal ( sorted ( g . nodes ( ) ) , [ '<STR_LIT:a>' , '<STR_LIT:b>' , '<STR_LIT:c>' ] ) <EOL> assert_equal ( g . size ( ) , <NUM_LIT:3> ) <EOL> def test_complete_digraph ( self ) : <EOL> for m in [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:5> ] : <EOL> g = complete_graph ( m , create_using = nx . DiGraph ( ) ) <EOL> assert_true ( number_of_nodes ( g ) == m ) <EOL> assert_true ( number_of_edges ( g ) == m * ( m - <NUM_LIT:1> ) ) <EOL> g = complete_graph ( "<STR_LIT:abc>" , create_using = nx . DiGraph ( ) ) <EOL> assert_equal ( len ( g ) , <NUM_LIT:3> ) <EOL> assert_equal ( g . size ( ) , <NUM_LIT:6> ) <EOL> assert_true ( g . is_directed ( ) ) <EOL> def test_circular_ladder_graph ( self ) : <EOL> G = circular_ladder_graph ( <NUM_LIT:5> ) <EOL> assert_raises ( networkx . exception . NetworkXError , circular_ladder_graph , <EOL> <NUM_LIT:5> , create_using = DiGraph ( ) ) <EOL> mG = circular_ladder_graph ( <NUM_LIT:5> , create_using = MultiGraph ( ) ) <EOL> assert_equal ( sorted ( mG . edges ( ) ) , sorted ( G . edges ( ) ) ) <EOL> def test_circulant_graph ( self ) : <EOL> Ci6_1 = circulant_graph ( <NUM_LIT:6> , [ <NUM_LIT:1> ] ) <EOL> C6 = cycle_graph ( <NUM_LIT:6> ) <EOL> assert_equal ( sorted ( Ci6_1 . edges ( ) ) , sorted ( C6 . edges ( ) ) ) <EOL> Ci7 = circulant_graph ( <NUM_LIT:7> , [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] ) <EOL> K7 = complete_graph ( <NUM_LIT:7> ) <EOL> assert_equal ( sorted ( Ci7 . edges ( ) ) , sorted ( K7 . edges ( ) ) ) <EOL> Ci6_1_3 = circulant_graph ( <NUM_LIT:6> , [ <NUM_LIT:1> , <NUM_LIT:3> ] ) <EOL> K3_3 = complete_bipartite_graph ( <NUM_LIT:3> , <NUM_LIT:3> ) <EOL> assert_true ( is_isomorphic ( Ci6_1_3 , K3_3 ) ) <EOL> def test_cycle_graph ( self ) : <EOL> G = cycle_graph ( <NUM_LIT:4> ) <EOL> assert_equal ( sorted ( G . edges ( ) ) , [ ( <NUM_LIT:0> , <NUM_LIT:1> ) , ( <NUM_LIT:0> , <NUM_LIT:3> ) , ( <NUM_LIT:1> , <NUM_LIT:2> ) , ( <NUM_LIT:2> , <NUM_LIT:3> ) ] ) <EOL> mG = cycle_graph ( <NUM_LIT:4> , create_using = MultiGraph ( ) ) <EOL> assert_equal ( sorted ( mG . edges ( ) ) , [ ( <NUM_LIT:0> , <NUM_LIT:1> ) , ( <NUM_LIT:0> , <NUM_LIT:3> ) , ( <NUM_LIT:1> , <NUM_LIT:2> ) , ( <NUM_LIT:2> , <NUM_LIT:3> ) ] ) <EOL> G = cycle_graph ( <NUM_LIT:4> , create_using = DiGraph ( ) ) <EOL> assert_false ( G . has_edge ( <NUM_LIT:2> , <NUM_LIT:1> ) ) <EOL> assert_true ( G . has_edge ( <NUM_LIT:1> , <NUM_LIT:2> ) ) <EOL> assert_true ( G . is_directed ( ) ) <EOL> G = cycle_graph ( "<STR_LIT:abc>" ) <EOL> assert_equal ( len ( G ) , <NUM_LIT:3> ) <EOL> assert_equal ( G . size ( ) , <NUM_LIT:3> ) <EOL> g = cycle_graph ( "<STR_LIT:abc>" , nx . DiGraph ( ) ) <EOL> assert_equal ( len ( g ) , <NUM_LIT:3> ) <EOL> assert_equal ( g . size ( ) , <NUM_LIT:3> ) <EOL> assert_true ( g . is_directed ( ) ) <EOL> def test_dorogovtsev_goltsev_mendes_graph ( self ) : <EOL> G = dorogovtsev_goltsev_mendes_graph ( <NUM_LIT:0> ) <EOL> assert_equal ( sorted ( G . edges ( ) ) , [ ( <NUM_LIT:0> , <NUM_LIT:1> ) ] ) <EOL> assert_equal ( list ( G ) , [ <NUM_LIT:0> , <NUM_LIT:1> ] ) <EOL> G = dorogovtsev_goltsev_mendes_graph ( <NUM_LIT:1> ) <EOL> assert_equal ( sorted ( G . edges ( ) ) , [ ( <NUM_LIT:0> , <NUM_LIT:1> ) , ( <NUM_LIT:0> , <NUM_LIT:2> ) , ( <NUM_LIT:1> , <NUM_LIT:2> ) ] ) <EOL> assert_equal ( average_clustering ( G ) , <NUM_LIT:1.0> ) <EOL> assert_equal ( sorted ( triangles ( G ) . values ( ) ) , [ <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ] ) <EOL> G = dorogovtsev_goltsev_mendes_graph ( <NUM_LIT:10> ) <EOL> assert_equal ( number_of_nodes ( G ) , <NUM_LIT> ) <EOL> assert_equal ( number_of_edges ( G ) , <NUM_LIT> ) <EOL> assert_equal ( G . degree ( <NUM_LIT:0> ) , <NUM_LIT> ) <EOL> assert_equal ( G . degree ( <NUM_LIT:1> ) , <NUM_LIT> ) <EOL> assert_equal ( G . degree ( <NUM_LIT:2> ) , <NUM_LIT> ) <EOL> assert_raises ( networkx . exception . NetworkXError , <EOL> dorogovtsev_goltsev_mendes_graph , <NUM_LIT:7> , <EOL> create_using = DiGraph ( ) ) <EOL> assert_raises ( networkx . exception . NetworkXError , <EOL> dorogovtsev_goltsev_mendes_graph , <NUM_LIT:7> , <EOL> create_using = MultiGraph ( ) ) <EOL> def test_empty_graph ( self ) : <EOL> G = empty_graph ( ) <EOL> assert_equal ( number_of_nodes ( G ) , <NUM_LIT:0> ) <EOL> G = empty_graph ( <NUM_LIT> ) <EOL> assert_equal ( number_of_nodes ( G ) , <NUM_LIT> ) <EOL> assert_equal ( number_of_edges ( G ) , <NUM_LIT:0> ) <EOL> assert_equal ( G . name , '<STR_LIT>' ) <EOL> G = empty_graph ( "<STR_LIT:abc>" ) <EOL> assert_equal ( len ( G ) , <NUM_LIT:3> ) <EOL> assert_equal ( G . size ( ) , <NUM_LIT:0> ) <EOL> G = empty_graph ( <NUM_LIT> , create_using = DiGraph ( name = "<STR_LIT>" ) ) <EOL> assert_equal ( number_of_nodes ( G ) , <NUM_LIT> ) <EOL> assert_equal ( number_of_edges ( G ) , <NUM_LIT:0> ) <EOL> assert_equal ( G . name , '<STR_LIT>' ) <EOL> assert_true ( isinstance ( G , DiGraph ) ) <EOL> G = empty_graph ( <NUM_LIT> , create_using = MultiGraph ( name = "<STR_LIT>" ) ) <EOL> assert_equal ( number_of_nodes ( G ) , <NUM_LIT> ) <EOL> assert_equal ( number_of_edges ( G ) , <NUM_LIT:0> ) <EOL> assert_equal ( G . name , '<STR_LIT>' ) <EOL> assert_true ( isinstance ( G , MultiGraph ) ) <EOL> pete = petersen_graph ( ) <EOL> G = empty_graph ( <NUM_LIT> , create_using = pete ) <EOL> assert_equal ( number_of_nodes ( G ) , <NUM_LIT> ) <EOL> assert_equal ( number_of_edges ( G ) , <NUM_LIT:0> ) <EOL> assert_equal ( G . name , '<STR_LIT>' ) <EOL> assert_true ( isinstance ( G , Graph ) ) <EOL> def test_grid_2d_graph ( self ) : <EOL> n = <NUM_LIT:5> ; m = <NUM_LIT:6> <EOL> G = grid_2d_graph ( n , m ) <EOL> assert_equal ( number_of_nodes ( G ) , n * m ) <EOL> assert_equal ( degree_histogram ( G ) , [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:4> , <NUM_LIT:2> * ( n + m ) - <NUM_LIT:8> , ( n - <NUM_LIT:2> ) * ( m - <NUM_LIT:2> ) ] ) <EOL> DG = grid_2d_graph ( n , m , create_using = DiGraph ( ) ) <EOL> assert_equal ( DG . succ , G . adj ) <EOL> assert_equal ( DG . pred , G . adj ) <EOL> MG = grid_2d_graph ( n , m , create_using = MultiGraph ( ) ) <EOL> assert_equal ( sorted ( MG . edges ( ) ) , sorted ( G . edges ( ) ) ) <EOL> g = grid_2d_graph ( range ( n ) , range ( m ) ) <EOL> assert_equal ( sorted ( g . edges ( ) ) , sorted ( G . edges ( ) ) ) <EOL> def test_grid_graph ( self ) : <EOL> """<STR_LIT>""" <EOL> for n , m in [ ( <NUM_LIT:3> , <NUM_LIT:5> ) , ( <NUM_LIT:5> , <NUM_LIT:3> ) , ( <NUM_LIT:4> , <NUM_LIT:5> ) , ( <NUM_LIT:5> , <NUM_LIT:4> ) ] : <EOL> dim = [ n , m ] <EOL> g = grid_graph ( dim ) <EOL> assert_equal ( number_of_nodes ( g ) , n * m ) <EOL> assert_equal ( degree_histogram ( g ) , [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:4> , <NUM_LIT:2> * ( n + m ) - <NUM_LIT:8> , ( n - <NUM_LIT:2> ) * ( m - <NUM_LIT:2> ) ] ) <EOL> assert_equal ( dim , [ n , m ] ) <EOL> for n , m in [ ( <NUM_LIT:1> , <NUM_LIT:5> ) , ( <NUM_LIT:5> , <NUM_LIT:1> ) ] : <EOL> dim = [ n , m ] <EOL> g = grid_graph ( dim ) <EOL> assert_equal ( number_of_nodes ( g ) , n * m ) <EOL> assert_true ( is_isomorphic ( g , path_graph ( <NUM_LIT:5> ) ) ) <EOL> assert_equal ( dim , [ n , m ] ) <EOL> g = grid_graph ( [ range ( <NUM_LIT:7> , <NUM_LIT:9> ) , range ( <NUM_LIT:3> , <NUM_LIT:6> ) ] ) <EOL> assert_equal ( number_of_nodes ( g ) , <NUM_LIT:2> * <NUM_LIT:3> ) <EOL> assert_true ( is_isomorphic ( g , grid_graph ( [ <NUM_LIT:2> , <NUM_LIT:3> ] ) ) ) <EOL> def test_hypercube_graph ( self ) : <EOL> for n , G in [ ( <NUM_LIT:0> , null_graph ( ) ) , ( <NUM_LIT:1> , path_graph ( <NUM_LIT:2> ) ) , <EOL> ( <NUM_LIT:2> , cycle_graph ( <NUM_LIT:4> ) ) , ( <NUM_LIT:3> , cubical_graph ( ) ) ] : <EOL> g = hypercube_graph ( n ) <EOL> assert_true ( is_isomorphic ( g , G ) ) <EOL> g = hypercube_graph ( <NUM_LIT:4> ) <EOL> assert_equal ( degree_histogram ( g ) , [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:16> ] ) <EOL> g = hypercube_graph ( <NUM_LIT:5> ) <EOL> assert_equal ( degree_histogram ( g ) , [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:32> ] ) <EOL> g = hypercube_graph ( <NUM_LIT:6> ) <EOL> assert_equal ( degree_histogram ( g ) , [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:64> ] ) <EOL> def test_ladder_graph ( self ) : <EOL> for i , G in [ ( <NUM_LIT:0> , empty_graph ( <NUM_LIT:0> ) ) , ( <NUM_LIT:1> , path_graph ( <NUM_LIT:2> ) ) , <EOL> ( <NUM_LIT:2> , hypercube_graph ( <NUM_LIT:2> ) ) , ( <NUM_LIT:10> , grid_graph ( [ <NUM_LIT:2> , <NUM_LIT:10> ] ) ) ] : <EOL> assert_true ( is_isomorphic ( ladder_graph ( i ) , G ) ) <EOL> assert_raises ( networkx . exception . NetworkXError , <EOL> ladder_graph , <NUM_LIT:2> , create_using = DiGraph ( ) ) <EOL> g = ladder_graph ( <NUM_LIT:2> ) <EOL> mg = ladder_graph ( <NUM_LIT:2> , create_using = MultiGraph ( ) ) <EOL> assert_equal ( sorted ( mg . edges ( ) ) , sorted ( g . edges ( ) ) ) <EOL> def test_lollipop_graph ( self ) : <EOL> for m1 , m2 in [ ( <NUM_LIT:3> , <NUM_LIT:5> ) , ( <NUM_LIT:4> , <NUM_LIT:10> ) , ( <NUM_LIT:3> , <NUM_LIT:20> ) ] : <EOL> b = lollipop_graph ( m1 , m2 ) <EOL> assert_equal ( number_of_nodes ( b ) , m1 + m2 ) <EOL> assert_equal ( number_of_edges ( b ) , m1 * ( m1 - <NUM_LIT:1> ) / <NUM_LIT:2> + m2 ) <EOL> assert_equal ( b . name , <EOL> '<STR_LIT>' + str ( m1 ) + '<STR_LIT:U+002CU+0020>' + str ( m2 ) + '<STR_LIT:)>' ) <EOL> assert_raises ( networkx . exception . NetworkXError , <EOL> lollipop_graph , <NUM_LIT:1> , <NUM_LIT:20> ) <EOL> assert_raises ( networkx . exception . NetworkXError , <EOL> lollipop_graph , <NUM_LIT:5> , - <NUM_LIT:2> ) <EOL> for m1 , m2 in [ ( <NUM_LIT:2> , <NUM_LIT:5> ) , ( <NUM_LIT:2> , <NUM_LIT:10> ) , ( <NUM_LIT:2> , <NUM_LIT:20> ) ] : <EOL> b = lollipop_graph ( m1 , m2 ) <EOL> assert_true ( is_isomorphic ( b , path_graph ( m2 + <NUM_LIT:2> ) ) ) <EOL> assert_raises ( networkx . exception . NetworkXError , <EOL> lollipop_graph , m1 , m2 , create_using = DiGraph ( ) ) <EOL> mb = lollipop_graph ( m1 , m2 , create_using = MultiGraph ( ) ) <EOL> assert_equal ( sorted ( mb . edges ( ) ) , sorted ( b . edges ( ) ) ) <EOL> g = lollipop_graph ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ] , "<STR_LIT:abc>" ) <EOL> assert_equal ( len ( g ) , <NUM_LIT:7> ) <EOL> assert_equal ( g . size ( ) , <NUM_LIT:9> ) <EOL> def test_null_graph ( self ) : <EOL> assert_equal ( number_of_nodes ( null_graph ( ) ) , <NUM_LIT:0> ) <EOL> def test_path_graph ( self ) : <EOL> p = path_graph ( <NUM_LIT:0> ) <EOL> assert_true ( is_isomorphic ( p , null_graph ( ) ) ) <EOL> assert_equal ( p . name , '<STR_LIT>' ) <EOL> p = path_graph ( <NUM_LIT:1> ) <EOL> assert_true ( is_isomorphic ( p , empty_graph ( <NUM_LIT:1> ) ) ) <EOL> assert_equal ( p . name , '<STR_LIT>' ) <EOL> p = path_graph ( <NUM_LIT:10> ) <EOL> assert_true ( is_connected ( p ) ) <EOL> assert_equal ( sorted ( d for n , d in p . degree ( ) ) , <EOL> [ <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:2> ] ) <EOL> assert_equal ( p . order ( ) - <NUM_LIT:1> , p . size ( ) ) <EOL> dp = path_graph ( <NUM_LIT:3> , create_using = DiGraph ( ) ) <EOL> assert_true ( dp . has_edge ( <NUM_LIT:0> , <NUM_LIT:1> ) ) <EOL> assert_false ( dp . has_edge ( <NUM_LIT:1> , <NUM_LIT:0> ) ) <EOL> mp = path_graph ( <NUM_LIT:10> , create_using = MultiGraph ( ) ) <EOL> assert_equal ( sorted ( mp . edges ( ) ) , sorted ( p . edges ( ) ) ) <EOL> G = path_graph ( "<STR_LIT:abc>" ) <EOL> assert_equal ( len ( G ) , <NUM_LIT:3> ) <EOL> assert_equal ( G . size ( ) , <NUM_LIT:2> ) <EOL> g = path_graph ( "<STR_LIT:abc>" , nx . DiGraph ( ) ) <EOL> assert_equal ( len ( g ) , <NUM_LIT:3> ) <EOL> assert_equal ( g . size ( ) , <NUM_LIT:2> ) <EOL> assert_true ( g . is_directed ( ) ) <EOL> def test_periodic_grid_2d_graph ( self ) : <EOL> g = grid_2d_graph ( <NUM_LIT:0> , <NUM_LIT:0> , periodic = True ) <EOL> assert_equal ( dict ( g . degree ( ) ) , { } ) <EOL> for m , n , G in [ ( <NUM_LIT:2> , <NUM_LIT:2> , cycle_graph ( <NUM_LIT:4> ) ) , ( <NUM_LIT:1> , <NUM_LIT:7> , cycle_graph ( <NUM_LIT:7> ) ) , <EOL> ( <NUM_LIT:7> , <NUM_LIT:1> , cycle_graph ( <NUM_LIT:7> ) ) , ( <NUM_LIT:2> , <NUM_LIT:5> , circular_ladder_graph ( <NUM_LIT:5> ) ) , <EOL> ( <NUM_LIT:5> , <NUM_LIT:2> , circular_ladder_graph ( <NUM_LIT:5> ) ) , ( <NUM_LIT:2> , <NUM_LIT:4> , cubical_graph ( ) ) , <EOL> ( <NUM_LIT:4> , <NUM_LIT:2> , cubical_graph ( ) ) ] : <EOL> g = grid_2d_graph ( m , n , periodic = True ) <EOL> assert_true ( is_isomorphic ( g , G ) ) <EOL> DG = grid_2d_graph ( <NUM_LIT:4> , <NUM_LIT:2> , periodic = True , create_using = DiGraph ( ) ) <EOL> assert_equal ( DG . succ , g . adj ) <EOL> assert_equal ( DG . pred , g . adj ) <EOL> MG = grid_2d_graph ( <NUM_LIT:4> , <NUM_LIT:2> , periodic = True , create_using = MultiGraph ( ) ) <EOL> assert_equal ( sorted ( MG . edges ( ) ) , sorted ( g . edges ( ) ) ) <EOL> gg = grid_2d_graph ( range ( <NUM_LIT:4> ) , range ( <NUM_LIT:2> ) , periodic = True ) <EOL> assert_true ( is_isomorphic ( gg , g ) ) <EOL> ggg = grid_2d_graph ( "<STR_LIT>" , "<STR_LIT>" , periodic = True ) <EOL> assert_true ( is_isomorphic ( ggg , g ) ) <EOL> def test_star_graph ( self ) : <EOL> assert_true ( is_isomorphic ( star_graph ( <NUM_LIT:0> ) , empty_graph ( <NUM_LIT:1> ) ) ) <EOL> assert_true ( is_isomorphic ( star_graph ( <NUM_LIT:1> ) , path_graph ( <NUM_LIT:2> ) ) ) <EOL> assert_true ( is_isomorphic ( star_graph ( <NUM_LIT:2> ) , path_graph ( <NUM_LIT:3> ) ) ) <EOL> assert_true ( is_isomorphic ( star_graph ( <NUM_LIT:5> ) , nx . complete_bipartite_graph ( <NUM_LIT:1> , <NUM_LIT:5> ) ) ) <EOL> s = star_graph ( <NUM_LIT:10> ) <EOL> assert_equal ( sorted ( d for n , d in s . degree ( ) ) , <EOL> [ <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:10> ] ) <EOL> assert_raises ( networkx . exception . NetworkXError , <EOL> star_graph , <NUM_LIT:10> , create_using = DiGraph ( ) ) <EOL> ms = star_graph ( <NUM_LIT:10> , create_using = MultiGraph ( ) ) <EOL> assert_equal ( sorted ( ms . edges ( ) ) , sorted ( s . edges ( ) ) ) <EOL> G = star_graph ( "<STR_LIT>" ) <EOL> assert_equal ( len ( G ) , <NUM_LIT:7> ) <EOL> assert_equal ( G . size ( ) , <NUM_LIT:6> ) <EOL> def test_trivial_graph ( self ) : <EOL> assert_equal ( number_of_nodes ( trivial_graph ( ) ) , <NUM_LIT:1> ) <EOL> def test_wheel_graph ( self ) : <EOL> for n , G in [ ( <NUM_LIT:0> , null_graph ( ) ) , ( <NUM_LIT:1> , empty_graph ( <NUM_LIT:1> ) ) , <EOL> ( <NUM_LIT:2> , path_graph ( <NUM_LIT:2> ) ) , ( <NUM_LIT:3> , complete_graph ( <NUM_LIT:3> ) ) , <EOL> ( <NUM_LIT:4> , complete_graph ( <NUM_LIT:4> ) ) ] : <EOL> g = wheel_graph ( n ) <EOL> assert_true ( is_isomorphic ( g , G ) ) <EOL> assert_equal ( g . name , '<STR_LIT>' ) <EOL> g = wheel_graph ( <NUM_LIT:10> ) <EOL> assert_equal ( sorted ( d for n , d in g . degree ( ) ) , <EOL> [ <NUM_LIT:3> , <NUM_LIT:3> , <NUM_LIT:3> , <NUM_LIT:3> , <NUM_LIT:3> , <NUM_LIT:3> , <NUM_LIT:3> , <NUM_LIT:3> , <NUM_LIT:3> , <NUM_LIT:9> ] ) <EOL> assert_raises ( networkx . exception . NetworkXError , <EOL> wheel_graph , <NUM_LIT:10> , create_using = DiGraph ( ) ) <EOL> mg = wheel_graph ( <NUM_LIT:10> , create_using = MultiGraph ( ) ) <EOL> assert_equal ( sorted ( mg . edges ( ) ) , sorted ( g . edges ( ) ) ) <EOL> G = wheel_graph ( "<STR_LIT:abc>" ) <EOL> assert_equal ( len ( G ) , <NUM_LIT:3> ) <EOL> assert_equal ( G . size ( ) , <NUM_LIT:3> ) <EOL> def test_complete_0_partite_graph ( self ) : <EOL> """<STR_LIT>""" <EOL> G = nx . complete_multipartite_graph ( ) <EOL> H = nx . null_graph ( ) <EOL> assert_nodes_equal ( G , H ) <EOL> assert_edges_equal ( sorted ( G . edges ( ) ) , sorted ( H . edges ( ) ) ) <EOL> def test_complete_1_partite_graph ( self ) : <EOL> """<STR_LIT>""" <EOL> G = nx . complete_multipartite_graph ( <NUM_LIT:3> ) <EOL> H = nx . empty_graph ( <NUM_LIT:3> ) <EOL> assert_nodes_equal ( G , H ) <EOL> assert_edges_equal ( sorted ( G . edges ( ) ) , sorted ( H . edges ( ) ) ) <EOL> def test_complete_2_partite_graph ( self ) : <EOL> """<STR_LIT>""" <EOL> G = nx . complete_multipartite_graph ( <NUM_LIT:2> , <NUM_LIT:3> ) <EOL> H = nx . complete_bipartite_graph ( <NUM_LIT:2> , <NUM_LIT:3> ) <EOL> assert_nodes_equal ( G , H ) <EOL> assert_edges_equal ( sorted ( G . edges ( ) ) , sorted ( H . edges ( ) ) ) <EOL> def test_complete_multipartite_graph ( self ) : <EOL> """<STR_LIT>""" <EOL> G = nx . complete_multipartite_graph ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ) <EOL> blocks = [ ( <NUM_LIT:0> , <NUM_LIT:1> ) , ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ) , ( <NUM_LIT:5> , <NUM_LIT:6> , <NUM_LIT:7> , <NUM_LIT:8> ) ] <EOL> for block in blocks : <EOL> for u , v in itertools . combinations_with_replacement ( block , <NUM_LIT:2> ) : <EOL> assert_true ( v not in G [ u ] ) <EOL> assert_equal ( G . node [ u ] , G . node [ v ] ) <EOL> for ( block1 , block2 ) in itertools . combinations ( blocks , <NUM_LIT:2> ) : <EOL> for u , v in itertools . product ( block1 , block2 ) : <EOL> assert_true ( v in G [ u ] ) <EOL> assert_not_equal ( G . node [ u ] , G . node [ v ] ) </s>
