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


Python GraphDatabase.all_edges方法代码示例

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


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

示例1: test_basic

# 需要导入模块: from graphserver.graphdb import GraphDatabase [as 别名]
# 或者: from graphserver.graphdb.GraphDatabase import all_edges [as 别名]
 def test_basic(self):
     g = Graph()
     g.add_vertex("A")
     g.add_vertex("B")
     g.add_edge("A", "B", Link())
     g.add_edge("A", "B", Street("foo", 20.0))
     gdb_file = os.path.dirname(__file__) + "unit_test.db"
     if os.path.exists(gdb_file):
         os.remove(gdb_file)        
     gdb = GraphDatabase(gdb_file)
     gdb.populate(g)
     
     list(gdb.execute("select * from resources"))
     assert "A" in list(gdb.all_vertex_labels())
     assert "B" in list(gdb.all_vertex_labels())
     assert glen(gdb.all_edges()) == 2
     assert glen(gdb.all_outgoing("A")) == 2
     assert glen(gdb.all_outgoing("B")) == 0
     assert glen(gdb.all_incoming("A")) == 0
     assert glen(gdb.all_incoming("B")) == 2
     assert glen(gdb.resources()) == 0
     assert gdb.num_vertices() == 2
     assert gdb.num_edges() == 2
     
     g.destroy()
     g = gdb.incarnate()
     
     list(gdb.execute("select * from resources"))
     assert "A" in list(gdb.all_vertex_labels())
     assert "B" in list(gdb.all_vertex_labels())
     assert glen(gdb.all_edges()) == 2
     assert glen(gdb.all_outgoing("A")) == 2
     assert glen(gdb.all_outgoing("B")) == 0
     assert glen(gdb.all_incoming("A")) == 0
     assert glen(gdb.all_incoming("B")) == 2
     assert glen(gdb.resources()) == 0
     assert gdb.num_vertices() == 2
     assert gdb.num_edges() == 2
     
     os.remove( gdb_file )
开发者ID:Jamie5,项目名称:graphserver,代码行数:42,代码来源:test_graph_database.py

示例2: main

# 需要导入模块: from graphserver.graphdb import GraphDatabase [as 别名]
# 或者: from graphserver.graphdb.GraphDatabase import all_edges [as 别名]
def main():
    if len(argv) < 2:
        print "usage: python import_ned.py graphdb_filename profiledb_filename"
        return
        
    graphdb_filename = argv[1]
    profiledb_filename = argv[2]
        
    gdb = GraphDatabase( graphdb_filename )
    profiledb = ProfileDB( profiledb_filename )
    
    n = gdb.num_edges()

    for i, (oid, vertex1, vertex2, edge) in enumerate( list(gdb.all_edges(include_oid=True)) ):
        if i%500==0: print "%s/%s"%(i,n)
        
        if isinstance( edge, Street ):
            rise, fall = get_rise_and_fall( profiledb.get( edge.name ) )
            edge.rise = rise
            edge.fall = fall
            
            gdb.remove_edge( oid )
            gdb.add_edge( vertex1, vertex2, edge )
开发者ID:Jamie5,项目名称:graphserver,代码行数:25,代码来源:gdb_import_ned.py


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