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


Python networkx.reverse方法代码示例

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


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

示例1: shallow_reverse

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import reverse [as 别名]
def shallow_reverse(g):
    """
    Make a shallow copy of a directional graph and reverse the edges. This is a workaround to solve the issue that one
    cannot easily make a shallow reversed copy of a graph in NetworkX 2, since networkx.reverse(copy=False) now returns
    a GraphView, and GraphViews are always read-only.

    :param networkx.DiGraph g:  The graph to reverse.
    :return:                    A new networkx.DiGraph that has all nodes and all edges of the original graph, with
                                edges reversed.
    """

    new_g = networkx.DiGraph()

    new_g.add_nodes_from(g.nodes())
    for src, dst, data in g.edges(data=True):
        new_g.add_edge(dst, src, **data)

    return new_g 
开发者ID:angr,项目名称:angr,代码行数:20,代码来源:graph.py

示例2: __init__

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import reverse [as 别名]
def __init__(self, graph, entry_node, successors_func=None, reverse=False):

        self._l = logging.getLogger("utils.graph.dominators")
        self._graph_successors_func = successors_func

        self._reverse = reverse  # Set it to True to generate a post-dominator tree.

        # Temporary variables
        self._ancestor = None
        self._semi = None
        self._label = None

        # Output
        self.dom = None
        self.prepared_graph = None

        self._construct(graph, entry_node) 
开发者ID:angr,项目名称:angr,代码行数:19,代码来源:graph.py

示例3: test_reverse1

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import reverse [as 别名]
def test_reverse1():
    # Other tests for reverse are done by the DiGraph and MultiDigraph.
    G1=nx.Graph()
    assert_raises(nx.NetworkXError, nx.reverse, G1) 
开发者ID:SpaceGroupUCL,项目名称:qgisSpaceSyntaxToolkit,代码行数:6,代码来源:test_unary.py

示例4: test_reverse1

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import reverse [as 别名]
def test_reverse1():
    # Other tests for reverse are done by the DiGraph and MultiDigraph.
    G1 = nx.Graph()
    assert_raises(nx.NetworkXError, nx.reverse, G1) 
开发者ID:holzschu,项目名称:Carnets,代码行数:6,代码来源:test_unary.py


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