<s> from itertools import chain <EOL> import networkx as nx <EOL> from nose . tools import * <EOL> class TestIsSemiconnected ( object ) : <EOL> def test_undirected ( self ) : <EOL> assert_raises ( nx . NetworkXNotImplemented , nx . is_semiconnected , <EOL> nx . Graph ( ) ) <EOL> assert_raises ( nx . NetworkXNotImplemented , nx . is_semiconnected , <EOL> nx . MultiGraph ( ) ) <EOL> def test_empty ( self ) : <EOL> assert_raises ( nx . NetworkXPointlessConcept , nx . is_semiconnected , <EOL> nx . DiGraph ( ) ) <EOL> assert_raises ( nx . NetworkXPointlessConcept , nx . is_semiconnected , <EOL> nx . MultiDiGraph ( ) ) <EOL> def test_single_node_graph ( self ) : <EOL> G = nx . DiGraph ( ) <EOL> G . add_node ( <NUM_LIT:0> ) <EOL> ok_ ( nx . is_semiconnected ( G ) ) <EOL> def test_path ( self ) : <EOL> G = nx . path_graph ( <NUM_LIT:100> , create_using = nx . DiGraph ( ) ) <EOL> ok_ ( nx . is_semiconnected ( G ) ) <EOL> G . add_edge ( <NUM_LIT:100> , <NUM_LIT> ) <EOL> ok_ ( not nx . is_semiconnected ( G ) ) <EOL> def test_cycle ( self ) : <EOL> G = nx . cycle_graph ( <NUM_LIT:100> , create_using = nx . DiGraph ( ) ) <EOL> ok_ ( nx . is_semiconnected ( G ) ) <EOL> G = nx . path_graph ( <NUM_LIT:100> , create_using = nx . DiGraph ( ) ) <EOL> G . add_edge ( <NUM_LIT:0> , <NUM_LIT> ) <EOL> ok_ ( nx . is_semiconnected ( G ) ) <EOL> def test_tree ( self ) : <EOL> G = nx . DiGraph ( ) <EOL> G . add_edges_from ( chain . from_iterable ( [ ( i , <NUM_LIT:2> * i + <NUM_LIT:1> ) , ( i , <NUM_LIT:2> * i + <NUM_LIT:2> ) ] <EOL> for i in range ( <NUM_LIT:100> ) ) ) <EOL> ok_ ( not nx . is_semiconnected ( G ) ) <EOL> def test_dumbbell ( self ) : <EOL> G = nx . cycle_graph ( <NUM_LIT:100> , create_using = nx . DiGraph ( ) ) <EOL> G . add_edges_from ( ( i + <NUM_LIT:100> , ( i + <NUM_LIT:1> ) % <NUM_LIT:100> + <NUM_LIT:100> ) for i in range ( <NUM_LIT:100> ) ) <EOL> ok_ ( not nx . is_semiconnected ( G ) ) <EOL> G . add_edge ( <NUM_LIT:100> , <NUM_LIT> ) <EOL> ok_ ( nx . is_semiconnected ( G ) ) <EOL> def test_alternating_path ( self ) : <EOL> G = nx . DiGraph ( chain . from_iterable ( [ ( i , i - <NUM_LIT:1> ) , ( i , i + <NUM_LIT:1> ) ] <EOL> for i in range ( <NUM_LIT:0> , <NUM_LIT:100> , <NUM_LIT:2> ) ) ) <EOL> ok_ ( not nx . is_semiconnected ( G ) ) </s>
