1 #!/usr/bin/env python 2 3 """line graph 4 ---------- 5 """ 6 7 import networkx as nx 8 from nose.tools import * 9 10 11 class TestGeneratorLine(): 12 def test_line(self): 13 G=nx.star_graph(5) 14 L=nx.line_graph(G) 15 assert_true(nx.is_isomorphic(L,nx.complete_graph(5))) 16 G=nx.path_graph(5) 17 L=nx.line_graph(G) 18 assert_true(nx.is_isomorphic(L,nx.path_graph(4))) 19 G=nx.cycle_graph(5) 20 L=nx.line_graph(G) 21 assert_true(nx.is_isomorphic(L,G)) 22 G=nx.DiGraph() 23 G.add_edges_from([(0,1),(0,2),(0,3)]) 24 L=nx.line_graph(G) 25 assert_equal(L.adj, {}) 26 G=nx.DiGraph() 27 G.add_edges_from([(0,1),(1,2),(2,3)]) 28 L=nx.line_graph(G) 29 assert_equal(sorted(L.edges()), [((0, 1), (1, 2)), ((1, 2), (2, 3))]) 30 31