<s> import unittest <EOL> import random <EOL> from zen import * <EOL> class LocalClusteringCoefficientTestCase ( unittest . TestCase ) : <EOL> def test_simple ( self ) : <EOL> G = DiGraph ( ) <EOL> G . add_edge ( '<STR_LIT:x>' , '<STR_LIT:y>' ) <EOL> G . add_edge ( '<STR_LIT:x>' , '<STR_LIT:z>' ) <EOL> G . add_edge ( '<STR_LIT:y>' , '<STR_LIT:z>' ) <EOL> x = clustering . lcc ( G ) <EOL> self . assertEqual ( x [ '<STR_LIT:x>' ] , <NUM_LIT:0.5> ) <EOL> G . add_edge ( '<STR_LIT:z>' , '<STR_LIT:y>' ) <EOL> x = clustering . lcc ( G ) <EOL> self . assertEqual ( x [ '<STR_LIT:x>' ] , <NUM_LIT:1.0> ) <EOL> x = clustering . ncc ( G ) <EOL> self . assertAlmostEqual ( x , <NUM_LIT> ) <EOL> def test_zero_outdegree ( self ) : <EOL> G = DiGraph ( ) <EOL> G . add_edge ( '<STR_LIT:x>' , '<STR_LIT:y>' ) <EOL> x = clustering . lcc ( G ) <EOL> self . assertEqual ( x [ '<STR_LIT:y>' ] , <NUM_LIT:0> ) <EOL> def test_simple2 ( self ) : <EOL> G = DiGraph ( ) <EOL> n1 = G . add_node ( ) <EOL> n2 = G . add_node ( ) <EOL> G . add_edge_ ( n1 , n2 ) <EOL> for i in range ( <NUM_LIT:2> , <NUM_LIT:100> ) : <EOL> n = G . add_node ( ) <EOL> G . add_edge_ ( n1 , n ) <EOL> G . add_edge_ ( n , n - <NUM_LIT:1> ) <EOL> G . add_edge_ ( n2 , <NUM_LIT> ) <EOL> x = clustering . lcc ( G ) <EOL> class GlobalClusteringCoefficientTestCase ( unittest . TestCase ) : <EOL> def test_simple_dir ( self ) : <EOL> G = DiGraph ( ) <EOL> G . add_edge ( '<STR_LIT:x>' , '<STR_LIT:y>' ) <EOL> G . add_edge ( '<STR_LIT:x>' , '<STR_LIT:z>' ) <EOL> G . add_edge ( '<STR_LIT:y>' , '<STR_LIT:z>' ) <EOL> x = clustering . gcc ( G ) <EOL> self . assertEqual ( x , <NUM_LIT:0.5> ) <EOL> G . add_edge ( '<STR_LIT:z>' , '<STR_LIT:y>' ) <EOL> x = clustering . gcc ( G ) <EOL> self . assertEqual ( x , <NUM_LIT:1.0> ) <EOL> def test_simple_udir ( self ) : <EOL> G = Graph ( ) <EOL> G . add_edge ( '<STR_LIT:x>' , '<STR_LIT:y>' ) <EOL> G . add_edge ( '<STR_LIT:x>' , '<STR_LIT:z>' ) <EOL> G . add_edge ( '<STR_LIT:y>' , '<STR_LIT:z>' ) <EOL> x = clustering . gcc ( G ) <EOL> self . assertEqual ( x , <NUM_LIT:1.0> ) <EOL> G . add_edge ( '<STR_LIT:z>' , '<STR_LIT:w>' ) <EOL> x = clustering . gcc ( G ) <EOL> self . assertAlmostEqual ( x , <NUM_LIT> / <NUM_LIT> ) <EOL> def test_zero_outdegree ( self ) : <EOL> G = DiGraph ( ) <EOL> G . add_edge ( '<STR_LIT:x>' , '<STR_LIT:y>' ) <EOL> x = clustering . gcc ( G ) <EOL> self . assertEqual ( x , <NUM_LIT:0> ) <EOL> def test_simple2 ( self ) : <EOL> G = DiGraph ( ) <EOL> n1 = G . add_node ( ) <EOL> n2 = G . add_node ( ) <EOL> G . add_edge_ ( n1 , n2 ) <EOL> for i in range ( <NUM_LIT:2> , <NUM_LIT:100> ) : <EOL> n = G . add_node ( ) <EOL> G . add_edge_ ( n1 , n ) <EOL> G . add_edge_ ( n , n - <NUM_LIT:1> ) <EOL> G . add_edge_ ( n2 , <NUM_LIT> ) <EOL> x = clustering . gcc ( G ) </s>
