def test_parse_multigraph_graph(self):
     graph_data = ':An'
     G = nx.parse_sparse6(graph_data)
     assert_true(type(G), nx.Graph)
     multigraph_data = ':Ab'
     M = nx.parse_sparse6(multigraph_data)
     assert_true(type(M), nx.MultiGraph)
Beispiel #2
0
 def test_parse_multigraph_graph(self):
     graph_data = ':An'
     G = nx.parse_sparse6(graph_data)
     assert_true(type(G), nx.Graph)
     multigraph_data = ':Ab'
     M = nx.parse_sparse6(multigraph_data)
     assert_true(type(M), nx.MultiGraph)
 def test_read_sparse6(self):
     data = """:Q___eDcdFcDeFcE`GaJ`IaHbKNbLM"""
     G = nx.parse_sparse6(data)
     fh = StringIO(data)
     Gin = nx.read_sparse6(fh)
     assert_equal(sorted(G.nodes()), sorted(Gin.nodes()))
     assert_equal(sorted(G.edges()), sorted(Gin.edges()))
Beispiel #4
0
 def test_read_sparse6(self):
     data=""":Q___eDcdFcDeFcE`GaJ`IaHbKNbLM"""
     G=nx.parse_sparse6(data)
     fh = StringIO(data)
     Gin=nx.read_sparse6(fh)
     assert_equal(sorted(G.nodes()),sorted(Gin.nodes()))
     assert_equal(sorted(G.edges()),sorted(Gin.edges()))
 def test_generate_and_parse_sparse6(self):
     for i in list(range(13)) + [31, 47, 62, 63, 64, 72]:
         m = min(2 * i, i * i // 2)
         g = nx.random_graphs.gnm_random_graph(i, m, seed=i)
         gstr = nx.generate_sparse6(g, header=False)
         g2 = nx.parse_sparse6(gstr)
         assert_equal(g2.order(), g.order())
         assert_equal(sorted(g2.edges()), sorted(g.edges()))
Beispiel #6
0
 def test_generate_and_parse_sparse6(self):
     for i in list(range(13)) + [31, 47, 62, 63, 64, 72]:
         m = min(2 * i, i * i // 2)
         g = nx.random_graphs.gnm_random_graph(i, m, seed=i)
         gstr = nx.generate_sparse6(g, header=False)
         g2 = nx.parse_sparse6(gstr)
         assert_equal(g2.order(), g.order())
         assert_equal(sorted(g2.edges()), sorted(g.edges()))
Beispiel #7
0
def graphs_flow(dirname):
    g_files = [str(z) + ".s6" for z in
               sorted([int(x.split('.')[0]) for x in os.listdir(dirname)])]
    for f in g_files:
        with open(os.path.join(dirname, f), 'rb') as s6:
            for encoded_graph in s6:
                g = nx.parse_sparse6(encoded_graph.strip())
                yield igraph.Graph(edges=g.edges())
Beispiel #8
0
def graphs_flow(dirname):
    g_files = [
        str(z) + ".s6"
        for z in sorted([int(x.split('.')[0]) for x in os.listdir(dirname)])
    ]
    for f in g_files:
        with open(os.path.join(dirname, f), 'rb') as s6:
            for encoded_graph in s6:
                g = nx.parse_sparse6(encoded_graph.strip())
                yield igraph.Graph(edges=g.edges())
Beispiel #9
0
 def test_read_sparse6(self):
     data=""":Q___eDcdFcDeFcE`GaJ`IaHbKNbLM"""
     G=nx.parse_sparse6(data)
     (fd,fname)=tempfile.mkstemp()
     fh=open(fname,'w')
     b=fh.write(data)
     fh.close()
     Gin=nx.read_sparse6(fname)
     assert_equal(sorted(G.nodes()),sorted(Gin.nodes()))
     assert_equal(sorted(G.edges()),sorted(Gin.edges()))
     os.close(fd)
     os.unlink(fname)
Beispiel #10
0
 def test_parse_sparse6(self):
     data=""":Q___eDcdFcDeFcE`GaJ`IaHbKNbLM"""
     G=nx.parse_sparse6(data)
     assert_equal(sorted(G.nodes()),
                  [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 
                   10, 11, 12, 13, 14, 15, 16, 17])
     assert_equal([e for e in sorted(G.edges())],
                  [(0, 1), (0, 2), (0, 3), (1, 12), (1, 14), (2, 13), 
                   (2, 15), (3, 16), (3, 17), (4, 7), (4, 9), (4, 11), 
                   (5, 6), (5, 8), (5, 9), (6, 10), (6, 11), (7, 8), 
                   (7, 10), (8, 12), (9, 15), (10, 14), (11, 13), 
                   (12, 16), (13, 17), (14, 17), (15, 16)])
Beispiel #11
0
 def test_parse_sparse6(self):
     data=""":Q___eDcdFcDeFcE`GaJ`IaHbKNbLM"""
     G=nx.parse_sparse6(data)
     assert_equal(sorted(G.nodes()),
                  [0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
                   10, 11, 12, 13, 14, 15, 16, 17])
     assert_equal([e for e in sorted(G.edges())],
                  [(0, 1), (0, 2), (0, 3), (1, 12), (1, 14), (2, 13),
                   (2, 15), (3, 16), (3, 17), (4, 7), (4, 9), (4, 11),
                   (5, 6), (5, 8), (5, 9), (6, 10), (6, 11), (7, 8),
                   (7, 10), (8, 12), (9, 15), (10, 14), (11, 13),
                   (12, 16), (13, 17), (14, 17), (15, 16)])
Beispiel #12
0
 def test_read_sparse6(self):
     data=""":Q___eDcdFcDeFcE`GaJ`IaHbKNbLM"""
     G=nx.parse_sparse6(data)
     (fd,fname)=tempfile.mkstemp()
     fh=open(fname,'w')
     b=fh.write(data)
     fh.close()
     Gin=nx.read_sparse6(fname)
     assert_equal(sorted(G.nodes()),sorted(Gin.nodes()))
     assert_equal(sorted(G.edges()),sorted(Gin.edges()))
     os.close(fd)
     os.unlink(fname)