<s> """<STR_LIT>""" <EOL> from nose . tools import assert_equal <EOL> from networkx import * <EOL> import os , tempfile <EOL> from io import open <EOL> from networkx . testing import * <EOL> class TestPajek ( object ) : <EOL> def setUp ( self ) : <EOL> self . data = """<STR_LIT>""" <EOL> self . G = nx . MultiDiGraph ( ) <EOL> self . G . add_nodes_from ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:C>' , '<STR_LIT>' ] ) <EOL> self . G . add_edges_from ( [ ( '<STR_LIT>' , '<STR_LIT>' ) , ( '<STR_LIT>' , '<STR_LIT>' ) , ( '<STR_LIT>' , '<STR_LIT:C>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , ( '<STR_LIT:C>' , '<STR_LIT:C>' ) , ( '<STR_LIT:C>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) ] ) <EOL> self . G . graph [ '<STR_LIT:name>' ] = '<STR_LIT>' <EOL> ( self . fd , self . fname ) = tempfile . mkstemp ( ) <EOL> fh = open ( self . fname , '<STR_LIT:wb>' ) <EOL> fh . write ( self . data . encode ( '<STR_LIT>' ) ) <EOL> fh . close ( ) <EOL> def tearDown ( self ) : <EOL> os . close ( self . fd ) <EOL> os . unlink ( self . fname ) <EOL> def test_parse_pajek_simple ( self ) : <EOL> data = """<STR_LIT>""" <EOL> G = parse_pajek ( data ) <EOL> assert_equal ( sorted ( G . nodes ( ) ) , [ '<STR_LIT:1>' , '<STR_LIT:2>' ] ) <EOL> assert_edges_equal ( G . edges ( ) , [ ( '<STR_LIT:1>' , '<STR_LIT:2>' ) , ( '<STR_LIT:1>' , '<STR_LIT:2>' ) ] ) <EOL> def test_parse_pajek ( self ) : <EOL> G = parse_pajek ( self . data ) <EOL> assert_equal ( sorted ( G . nodes ( ) ) , [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:C>' , '<STR_LIT>' ] ) <EOL> assert_edges_equal ( G . edges ( ) , [ ( '<STR_LIT>' , '<STR_LIT>' ) , ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT:C>' ) , ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT:C>' , '<STR_LIT:C>' ) , ( '<STR_LIT:C>' , '<STR_LIT>' ) , ( '<STR_LIT>' , '<STR_LIT>' ) ] ) <EOL> def test_read_pajek ( self ) : <EOL> G = parse_pajek ( self . data ) <EOL> Gin = read_pajek ( self . fname ) <EOL> assert_equal ( sorted ( G . nodes ( ) ) , sorted ( Gin . nodes ( ) ) ) <EOL> assert_edges_equal ( G . edges ( ) , Gin . edges ( ) ) <EOL> assert_equal ( self . G . graph , Gin . graph ) <EOL> for n in G . node : <EOL> assert_equal ( G . node [ n ] , Gin . node [ n ] ) </s>
