当前位置: 首页>>代码示例>>Python>>正文


Python networkx.read_adjlist方法代码示例

本文整理汇总了Python中networkx.read_adjlist方法的典型用法代码示例。如果您正苦于以下问题:Python networkx.read_adjlist方法的具体用法?Python networkx.read_adjlist怎么用?Python networkx.read_adjlist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在networkx的用法示例。


在下文中一共展示了networkx.read_adjlist方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: read_adjlist

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import read_adjlist [as 别名]
def read_adjlist(self, filename):
        """ Read graph from adjacency file in which the edge must be unweighted
            the format of each line: v1 n1 n2 n3 ... nk
            :param filename: the filename of input file
        """
        self.G = nx.read_adjlist(filename, create_using=nx.DiGraph())
        for i, j in self.G.edges():
            self.G[i][j]['weight'] = 1.0
        self.encode_node() 
开发者ID:thunlp,项目名称:OpenNE,代码行数:11,代码来源:graph.py

示例2: read_adjlist

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import read_adjlist [as 别名]
def read_adjlist(self, filename):
        """ Read graph from adjacency file in which the edge must be unweighted
            the format of each line: v1 n1 n2 n3 ... nk
            :param filename: the filename of input file
        """
        self.G = nx.read_adjlist(filename, nodetype=int, create_using=nx.DiGraph())
        for i, j in self.G.edges():
            self.G[i][j]['weight'] = 1.0
        self.encode_node() 
开发者ID:xchadesi,项目名称:GPF,代码行数:11,代码来源:graph.py

示例3: test_adjlist_graph

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import read_adjlist [as 别名]
def test_adjlist_graph(self):
        G=self.G
        (fd,fname)=tempfile.mkstemp()
        nx.write_adjlist(G,fname)
        H=nx.read_adjlist(fname)
        H2=nx.read_adjlist(fname)
        assert_not_equal(H,H2) # they should be different graphs
        assert_nodes_equal(H.nodes(),G.nodes())
        assert_edges_equal(H.edges(),G.edges())
        os.close(fd)
        os.unlink(fname) 
开发者ID:SpaceGroupUCL,项目名称:qgisSpaceSyntaxToolkit,代码行数:13,代码来源:test_adjlist.py

示例4: test_adjlist_digraph

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import read_adjlist [as 别名]
def test_adjlist_digraph(self):
        G=self.DG
        (fd,fname)=tempfile.mkstemp()
        nx.write_adjlist(G,fname)
        H=nx.read_adjlist(fname,create_using=nx.DiGraph())
        H2=nx.read_adjlist(fname,create_using=nx.DiGraph())
        assert_not_equal(H,H2) # they should be different graphs
        assert_nodes_equal(H.nodes(),G.nodes())
        assert_edges_equal(H.edges(),G.edges())
        os.close(fd)
        os.unlink(fname) 
开发者ID:SpaceGroupUCL,项目名称:qgisSpaceSyntaxToolkit,代码行数:13,代码来源:test_adjlist.py

示例5: test_adjlist_integers

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import read_adjlist [as 别名]
def test_adjlist_integers(self):
        (fd,fname)=tempfile.mkstemp()
        G=nx.convert_node_labels_to_integers(self.G)
        nx.write_adjlist(G,fname)
        H=nx.read_adjlist(fname,nodetype=int)
        H2=nx.read_adjlist(fname,nodetype=int)
        assert_nodes_equal(H.nodes(),G.nodes())
        assert_edges_equal(H.edges(),G.edges())
        os.close(fd)
        os.unlink(fname) 
开发者ID:SpaceGroupUCL,项目名称:qgisSpaceSyntaxToolkit,代码行数:12,代码来源:test_adjlist.py

示例6: test_adjlist_multigraph

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import read_adjlist [as 别名]
def test_adjlist_multigraph(self):
        G=self.XG
        (fd,fname)=tempfile.mkstemp()
        nx.write_adjlist(G,fname)
        H=nx.read_adjlist(fname,nodetype=int,
                          create_using=nx.MultiGraph())
        H2=nx.read_adjlist(fname,nodetype=int,
                           create_using=nx.MultiGraph())
        assert_not_equal(H,H2) # they should be different graphs
        assert_nodes_equal(H.nodes(),G.nodes())
        assert_edges_equal(H.edges(),G.edges())
        os.close(fd)
        os.unlink(fname) 
开发者ID:SpaceGroupUCL,项目名称:qgisSpaceSyntaxToolkit,代码行数:15,代码来源:test_adjlist.py

示例7: test_adjlist_multidigraph

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import read_adjlist [as 别名]
def test_adjlist_multidigraph(self):
        G=self.XDG
        (fd,fname)=tempfile.mkstemp()
        nx.write_adjlist(G,fname)
        H=nx.read_adjlist(fname,nodetype=int,
                          create_using=nx.MultiDiGraph())
        H2=nx.read_adjlist(fname,nodetype=int,
                           create_using=nx.MultiDiGraph())
        assert_not_equal(H,H2) # they should be different graphs
        assert_nodes_equal(H.nodes(),G.nodes())
        assert_edges_equal(H.edges(),G.edges())
        os.close(fd)
        os.unlink(fname) 
开发者ID:SpaceGroupUCL,项目名称:qgisSpaceSyntaxToolkit,代码行数:15,代码来源:test_adjlist.py

示例8: test_adjlist_delimiter

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import read_adjlist [as 别名]
def test_adjlist_delimiter(self):
        fh=io.BytesIO()
        G = nx.path_graph(3)
        nx.write_adjlist(G, fh, delimiter=':')
        fh.seek(0)
        H = nx.read_adjlist(fh, nodetype=int, delimiter=':')
        assert_nodes_equal(H.nodes(),G.nodes())
        assert_edges_equal(H.edges(),G.edges()) 
开发者ID:SpaceGroupUCL,项目名称:qgisSpaceSyntaxToolkit,代码行数:10,代码来源:test_adjlist.py

示例9: test_adjlist_graph

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import read_adjlist [as 别名]
def test_adjlist_graph(self):
        G = self.G
        (fd, fname) = tempfile.mkstemp()
        nx.write_adjlist(G, fname)
        H = nx.read_adjlist(fname)
        H2 = nx.read_adjlist(fname)
        assert_not_equal(H, H2)  # they should be different graphs
        assert_nodes_equal(list(H), list(G))
        assert_edges_equal(list(H.edges()), list(G.edges()))
        os.close(fd)
        os.unlink(fname) 
开发者ID:holzschu,项目名称:Carnets,代码行数:13,代码来源:test_adjlist.py

示例10: test_adjlist_digraph

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import read_adjlist [as 别名]
def test_adjlist_digraph(self):
        G = self.DG
        (fd, fname) = tempfile.mkstemp()
        nx.write_adjlist(G, fname)
        H = nx.read_adjlist(fname, create_using=nx.DiGraph())
        H2 = nx.read_adjlist(fname, create_using=nx.DiGraph())
        assert_not_equal(H, H2)  # they should be different graphs
        assert_nodes_equal(list(H), list(G))
        assert_edges_equal(list(H.edges()), list(G.edges()))
        os.close(fd)
        os.unlink(fname) 
开发者ID:holzschu,项目名称:Carnets,代码行数:13,代码来源:test_adjlist.py

示例11: test_adjlist_integers

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import read_adjlist [as 别名]
def test_adjlist_integers(self):
        (fd, fname) = tempfile.mkstemp()
        G = nx.convert_node_labels_to_integers(self.G)
        nx.write_adjlist(G, fname)
        H = nx.read_adjlist(fname, nodetype=int)
        H2 = nx.read_adjlist(fname, nodetype=int)
        assert_nodes_equal(list(H), list(G))
        assert_edges_equal(list(H.edges()), list(G.edges()))
        os.close(fd)
        os.unlink(fname) 
开发者ID:holzschu,项目名称:Carnets,代码行数:12,代码来源:test_adjlist.py

示例12: test_adjlist_multidigraph

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import read_adjlist [as 别名]
def test_adjlist_multidigraph(self):
        G = self.XDG
        (fd, fname) = tempfile.mkstemp()
        nx.write_adjlist(G, fname)
        H = nx.read_adjlist(fname, nodetype=int,
                            create_using=nx.MultiDiGraph())
        H2 = nx.read_adjlist(fname, nodetype=int,
                             create_using=nx.MultiDiGraph())
        assert_not_equal(H, H2)  # they should be different graphs
        assert_nodes_equal(list(H), list(G))
        assert_edges_equal(list(H.edges()), list(G.edges()))
        os.close(fd)
        os.unlink(fname) 
开发者ID:holzschu,项目名称:Carnets,代码行数:15,代码来源:test_adjlist.py

示例13: test_adjlist_delimiter

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import read_adjlist [as 别名]
def test_adjlist_delimiter(self):
        fh = io.BytesIO()
        G = nx.path_graph(3)
        nx.write_adjlist(G, fh, delimiter=':')
        fh.seek(0)
        H = nx.read_adjlist(fh, nodetype=int, delimiter=':')
        assert_nodes_equal(list(H), list(G))
        assert_edges_equal(list(H.edges()), list(G.edges())) 
开发者ID:holzschu,项目名称:Carnets,代码行数:10,代码来源:test_adjlist.py

示例14: test_adjlist_graph

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import read_adjlist [as 别名]
def test_adjlist_graph(self):
        G=self.G
        (fd,fname)=tempfile.mkstemp()
        nx.write_adjlist(G,fname)
        H=nx.read_adjlist(fname)
        H2=nx.read_adjlist(fname)
        assert_not_equal(H,H2) # they should be different graphs
        assert_nodes_equal(list(H), list(G))
        assert_edges_equal(list(H.edges()), list(G.edges()))
        os.close(fd)
        os.unlink(fname) 
开发者ID:aws-samples,项目名称:aws-kube-codesuite,代码行数:13,代码来源:test_adjlist.py

示例15: test_adjlist_digraph

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import read_adjlist [as 别名]
def test_adjlist_digraph(self):
        G=self.DG
        (fd,fname)=tempfile.mkstemp()
        nx.write_adjlist(G,fname)
        H=nx.read_adjlist(fname,create_using=nx.DiGraph())
        H2=nx.read_adjlist(fname,create_using=nx.DiGraph())
        assert_not_equal(H,H2) # they should be different graphs
        assert_nodes_equal(list(H), list(G))
        assert_edges_equal(list(H.edges()), list(G.edges()))
        os.close(fd)
        os.unlink(fname) 
开发者ID:aws-samples,项目名称:aws-kube-codesuite,代码行数:13,代码来源:test_adjlist.py


注:本文中的networkx.read_adjlist方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。