當前位置: 首頁>>代碼示例>>Python>>正文


Python networkx.freeze方法代碼示例

本文整理匯總了Python中networkx.freeze方法的典型用法代碼示例。如果您正苦於以下問題:Python networkx.freeze方法的具體用法?Python networkx.freeze怎麽用?Python networkx.freeze使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在networkx的用法示例。


在下文中一共展示了networkx.freeze方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: is_frozen

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import freeze [as 別名]
def is_frozen(G):
    """Return True if graph is frozen.

    Parameters
    ----------
    G : graph
      A NetworkX graph

    See Also
    --------
    freeze
    """
    try:
        return G.frozen
    except AttributeError:
        return False 
開發者ID:SpaceGroupUCL,項目名稱:qgisSpaceSyntaxToolkit,代碼行數:18,代碼來源:function.py

示例2: subgraph_view

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import freeze [as 別名]
def subgraph_view(G, filter_node=no_filter, filter_edge=no_filter):
    newG = nx.freeze(G.__class__())
    newG._NODE_OK = filter_node
    newG._EDGE_OK = filter_edge

    # create view by assigning attributes from G
    newG._graph = G
    newG.graph = G.graph

    newG._node = FilterAtlas(G._node, filter_node)
    if G.is_multigraph():
        Adj = FilterMultiAdjacency

        def reverse_edge(u, v, k): return filter_edge(v, u, k)
    else:
        Adj = FilterAdjacency

        def reverse_edge(u, v): return filter_edge(v, u)
    if G.is_directed():
        newG._succ = Adj(G._succ, filter_node, filter_edge)
        newG._pred = Adj(G._pred, filter_node, reverse_edge)
        newG._adj = newG._succ
    else:
        newG._adj = Adj(G._adj, filter_node, filter_edge)
    return newG 
開發者ID:holzschu,項目名稱:Carnets,代碼行數:27,代碼來源:graphviews.py

示例3: is_frozen

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import freeze [as 別名]
def is_frozen(G):
    """Returns True if graph is frozen.

    Parameters
    ----------
    G : graph
      A NetworkX graph

    See Also
    --------
    freeze
    """
    try:
        return G.frozen
    except AttributeError:
        return False 
開發者ID:holzschu,項目名稱:Carnets,代碼行數:18,代碼來源:function.py

示例4: freeze

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import freeze [as 別名]
def freeze(self):
        """Freezes the graph so that no more mutations can occur."""
        if not self.frozen:
            nx.freeze(self)
        return self 
開發者ID:openstack,項目名稱:taskflow,代碼行數:7,代碼來源:graph.py

示例5: setUp

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import freeze [as 別名]
def setUp(self):
        G=nx.Graph(name="test")
        e=[('a','b'),('b','c'),('c','d'),('d','e'),('e','f'),('a','f')]
        G.add_edges_from(e,width=10)
        G.add_node('g',color='green')
        G.graph['number']=1
        DG=nx.DiGraph(G)
        MG=nx.MultiGraph(G)
        MG.add_edge('a', 'a')
        MDG=nx.MultiDiGraph(G)
        MDG.add_edge('a', 'a')
        fG = G.copy()
        fDG = DG.copy()
        fMG = MG.copy()
        fMDG = MDG.copy()
        nx.freeze(fG)
        nx.freeze(fDG)
        nx.freeze(fMG)
        nx.freeze(fMDG)
        self.G=G
        self.DG=DG
        self.MG=MG
        self.MDG=MDG
        self.fG=fG
        self.fDG=fDG
        self.fMG=fMG
        self.fMDG=fMDG 
開發者ID:SpaceGroupUCL,項目名稱:qgisSpaceSyntaxToolkit,代碼行數:29,代碼來源:test_gpickle.py

示例6: test_freeze

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import freeze [as 別名]
def test_freeze(self):
        G=nx.freeze(self.G)
        assert_equal(G.frozen,True)
        assert_raises(nx.NetworkXError, G.add_node, 1)
        assert_raises(nx.NetworkXError, G.add_nodes_from, [1])
        assert_raises(nx.NetworkXError, G.remove_node, 1)
        assert_raises(nx.NetworkXError, G.remove_nodes_from, [1])
        assert_raises(nx.NetworkXError, G.add_edge, 1,2)
        assert_raises(nx.NetworkXError, G.add_edges_from, [(1,2)])
        assert_raises(nx.NetworkXError, G.remove_edge, 1,2)
        assert_raises(nx.NetworkXError, G.remove_edges_from, [(1,2)])
        assert_raises(nx.NetworkXError, G.clear) 
開發者ID:SpaceGroupUCL,項目名稱:qgisSpaceSyntaxToolkit,代碼行數:14,代碼來源:test_function.py

示例7: test_is_frozen

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import freeze [as 別名]
def test_is_frozen(self):
        assert_equal(nx.is_frozen(self.G), False)
        G=nx.freeze(self.G)
        assert_equal(G.frozen, nx.is_frozen(self.G))
        assert_equal(G.frozen,True) 
開發者ID:SpaceGroupUCL,項目名稱:qgisSpaceSyntaxToolkit,代碼行數:7,代碼來源:test_function.py

示例8: freeze

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import freeze [as 別名]
def freeze(self):
        nx.freeze(self) 
開發者ID:djordon,項目名稱:queueing-tool,代碼行數:4,代碼來源:graph_wrapper.py

示例9: setUp

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import freeze [as 別名]
def setUp(self):
        G = nx.Graph(name="test")
        e = [('a', 'b'), ('b', 'c'), ('c', 'd'), ('d', 'e'), ('e', 'f'), ('a', 'f')]
        G.add_edges_from(e, width=10)
        G.add_node('g', color='green')
        G.graph['number'] = 1
        DG = nx.DiGraph(G)
        MG = nx.MultiGraph(G)
        MG.add_edge('a', 'a')
        MDG = nx.MultiDiGraph(G)
        MDG.add_edge('a', 'a')
        fG = G.copy()
        fDG = DG.copy()
        fMG = MG.copy()
        fMDG = MDG.copy()
        nx.freeze(fG)
        nx.freeze(fDG)
        nx.freeze(fMG)
        nx.freeze(fMDG)
        self.G = G
        self.DG = DG
        self.MG = MG
        self.MDG = MDG
        self.fG = fG
        self.fDG = fDG
        self.fMG = fMG
        self.fMDG = fMDG 
開發者ID:holzschu,項目名稱:Carnets,代碼行數:29,代碼來源:test_gpickle.py

示例10: generic_graph_view

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import freeze [as 別名]
def generic_graph_view(G, create_using=None):
    if create_using is None:
        newG = G.__class__()
    else:
        newG = nx.empty_graph(0, create_using)
    if G.is_multigraph() != newG.is_multigraph():
        raise NetworkXError("Multigraph for G must agree with create_using")
    newG = nx.freeze(newG)

    # create view by assigning attributes from G
    newG._graph = G
    newG.graph = G.graph

    newG._node = G._node
    if newG.is_directed():
        if G.is_directed():
            newG._succ = G._succ
            newG._pred = G._pred
            newG._adj = G._succ
        else:
            newG._succ = G._adj
            newG._pred = G._adj
            newG._adj = G._adj
    elif G.is_directed():
        if G.is_multigraph():
            newG._adj = UnionMultiAdjacency(G._succ, G._pred)
        else:
            newG._adj = UnionAdjacency(G._succ, G._pred)
    else:
        newG._adj = G._adj
    return newG 
開發者ID:holzschu,項目名稱:Carnets,代碼行數:33,代碼來源:graphviews.py

示例11: test_is_frozen

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import freeze [as 別名]
def test_is_frozen(self):
        assert_equal(nx.is_frozen(self.G), False)
        G = nx.freeze(self.G)
        assert_equal(G.frozen, nx.is_frozen(self.G))
        assert_equal(G.frozen, True) 
開發者ID:holzschu,項目名稱:Carnets,代碼行數:7,代碼來源:test_function.py

示例12: test_freeze

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import freeze [as 別名]
def test_freeze(self):
        G = nx.freeze(self.G)
        assert_equal(G.frozen, True)
        assert_raises(nx.NetworkXError, G.add_node, 1)
        assert_raises(nx.NetworkXError, G.add_nodes_from, [1])
        assert_raises(nx.NetworkXError, G.remove_node, 1)
        assert_raises(nx.NetworkXError, G.remove_nodes_from, [1])
        assert_raises(nx.NetworkXError, G.add_edge, 1, 2)
        assert_raises(nx.NetworkXError, G.add_edges_from, [(1, 2)])
        assert_raises(nx.NetworkXError, G.remove_edge, 1, 2)
        assert_raises(nx.NetworkXError, G.remove_edges_from, [(1, 2)])
        assert_raises(nx.NetworkXError, G.clear) 
開發者ID:aws-samples,項目名稱:aws-kube-codesuite,代碼行數:14,代碼來源:test_function.py

示例13: freeze

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import freeze [as 別名]
def freeze(G):
    """Modify graph to prevent further change by adding or removing
    nodes or edges.

    Node and edge data can still be modified.

    Parameters
    ----------
    G : graph
      A NetworkX graph

    Examples
    --------
    >>> G=nx.Graph()
    >>> G.add_path([0,1,2,3])
    >>> G=nx.freeze(G)
    >>> try:
    ...    G.add_edge(4,5)
    ... except nx.NetworkXError as e:
    ...    print(str(e))
    Frozen graph can't be modified

    Notes
    -----
    To "unfreeze" a graph you must make a copy by creating a new graph object:

    >>> graph = nx.path_graph(4)
    >>> frozen_graph = nx.freeze(graph)
    >>> unfrozen_graph = nx.Graph(frozen_graph)
    >>> nx.is_frozen(unfrozen_graph)
    False

    See Also
    --------
    is_frozen
    """
    G.add_node=frozen
    G.add_nodes_from=frozen
    G.remove_node=frozen
    G.remove_nodes_from=frozen
    G.add_edge=frozen
    G.add_edges_from=frozen
    G.remove_edge=frozen
    G.remove_edges_from=frozen
    G.clear=frozen
    G.frozen=True
    return G 
開發者ID:SpaceGroupUCL,項目名稱:qgisSpaceSyntaxToolkit,代碼行數:49,代碼來源:function.py

示例14: freeze

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import freeze [as 別名]
def freeze(G):
    """Modify graph to prevent further change by adding or removing
    nodes or edges.

    Node and edge data can still be modified.

    Parameters
    ----------
    G : graph
      A NetworkX graph

    Examples
    --------
    >>> G = nx.path_graph(4)
    >>> G = nx.freeze(G)
    >>> try:
    ...    G.add_edge(4, 5)
    ... except nx.NetworkXError as e:
    ...    print(str(e))
    Frozen graph can't be modified

    Notes
    -----
    To "unfreeze" a graph you must make a copy by creating a new graph object:

    >>> graph = nx.path_graph(4)
    >>> frozen_graph = nx.freeze(graph)
    >>> unfrozen_graph = nx.Graph(frozen_graph)
    >>> nx.is_frozen(unfrozen_graph)
    False

    See Also
    --------
    is_frozen
    """
    G.add_node = frozen
    G.add_nodes_from = frozen
    G.remove_node = frozen
    G.remove_nodes_from = frozen
    G.add_edge = frozen
    G.add_edges_from = frozen
    G.add_weighted_edges_from = frozen
    G.remove_edge = frozen
    G.remove_edges_from = frozen
    G.clear = frozen
    G.frozen = True
    return G 
開發者ID:holzschu,項目名稱:Carnets,代碼行數:49,代碼來源:function.py

示例15: freeze

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import freeze [as 別名]
def freeze(G):
    """Modify graph to prevent further change by adding or removing
    nodes or edges.

    Node and edge data can still be modified.

    Parameters
    ----------
    G : graph
      A NetworkX graph

    Examples
    --------
    >>> G = nx.path_graph(4)
    >>> G = nx.freeze(G)
    >>> try:
    ...    G.add_edge(4, 5)
    ... except nx.NetworkXError as e:
    ...    print(str(e))
    Frozen graph can't be modified

    Notes
    -----
    To "unfreeze" a graph you must make a copy by creating a new graph object:

    >>> graph = nx.path_graph(4)
    >>> frozen_graph = nx.freeze(graph)
    >>> unfrozen_graph = nx.Graph(frozen_graph)
    >>> nx.is_frozen(unfrozen_graph)
    False

    See Also
    --------
    is_frozen
    """
    G.add_node = frozen
    G.add_nodes_from = frozen
    G.remove_node = frozen
    G.remove_nodes_from = frozen
    G.add_edge = frozen
    G.add_edges_from = frozen
    G.remove_edge = frozen
    G.remove_edges_from = frozen
    G.clear = frozen
    G.frozen = True
    return G 
開發者ID:aws-samples,項目名稱:aws-kube-codesuite,代碼行數:48,代碼來源:function.py


注:本文中的networkx.freeze方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。