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


Python Graph.vs["point"]方法代码示例

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


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

示例1: part_three

# 需要导入模块: from igraph import Graph [as 别名]
# 或者: from igraph.Graph import vs["point"] [as 别名]

#.........这里部分代码省略.........
                        count_valid_cursor_positions += 1
                        # valid_cursor_local.append(cursor_pos[i]) # we also
                        # need to store the 'key' thinned points
                        valid_cursor_local.append((mapped_x, mapped_y))
                        valid_cursor_to_global.append((x, y))
                        # send values to global calculation to figure out the
                        # order of objects
                        valid_cursor_timestamps.append(t)
                        # print valid_cursor_local

            # print count_valid_cursor_positions
            # Get the thin of the image
            # Map valid neighbour points as skeleton points: snap to closest
            # Show the resulting image
            # Add Connected Object only if it has at least one valid cursor
            # position
            if len(valid_cursor_to_global) > 0:
                valid_cursors.append(valid_cursor_to_global)

            if len(valid_cursor_timestamps) > 0:
                valid_cursor_timestamps_global.append(valid_cursor_timestamps)

                # print 'global: ' + str(valid_cursor_to_global)
                # Here we have the all the cursor positions for this image.
                # Use these to find paths between the data point

            # Data points are in: data_pts_thinned, we can use this
            # datastructure to map data points to an index
            g = Graph()
            g.add_vertices(len(data_pts_thinned))
            # Create an adjacency matrix of data points - based on
            # 8-connectivity
            g.add_edges(compute_all_edges(data_pts_thinned))
            g.vs["point"] = data_pts_thinned
            # Calculate Paths between cursor positions
            path_points_ordered = []  # contains the temporal information, this
            #  is used for in-between points as well
            path_points = []

            for index_cursor_point in range(1, len(valid_cursor_local)):

                start_vertex = g.vs.find(
                    point=valid_cursor_local[index_cursor_point - 1])
                end_vertex = g.vs.find(
                    point=valid_cursor_local[index_cursor_point])
                shortest_path = g.get_all_shortest_paths(
                    start_vertex, end_vertex)

                if len(shortest_path) == 0:
                    print("In image: " + connected_image +
                          ", No path exists between: " +
                          str(data_pts_thinned[index_cursor_point - 1]) +
                          str(" and ") +
                          str(data_pts_thinned[index_cursor_point]))

                    path_points_ordered.append([])
                    # If no connection, still keep path_points_ordered same in
                    # size, need it at the end

                else:

                    # Path exists
                    path_between_strokes = []

                    for _path_points in shortest_path[0]:
                        # shortest path contains an array of shortest paths,
开发者ID:learningequality,项目名称:video-vectorization,代码行数:70,代码来源:defs.py


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