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


Python networkx.is_frozen方法代碼示例

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


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

示例1: _common_format

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import is_frozen [as 別名]
def _common_format(g, edge_notation):
    lines = []
    lines.append("Name: %s" % g.name)
    lines.append("Type: %s" % type(g).__name__)
    lines.append("Frozen: %s" % nx.is_frozen(g))
    lines.append("Density: %0.3f" % nx.density(g))
    lines.append("Nodes: %s" % g.number_of_nodes())
    for n, n_data in g.nodes(data=True):
        if n_data:
            lines.append("  - %s (%s)" % (n, n_data))
        else:
            lines.append("  - %s" % n)
    lines.append("Edges: %s" % g.number_of_edges())
    for (u, v, e_data) in g.edges(data=True):
        if e_data:
            lines.append("  %s %s %s (%s)" % (u, edge_notation, v, e_data))
        else:
            lines.append("  %s %s %s" % (u, edge_notation, v))
    return lines 
開發者ID:openstack,項目名稱:taskflow,代碼行數:21,代碼來源:graph.py

示例2: is_frozen

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import is_frozen [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

示例3: is_frozen

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import is_frozen [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: _remove_alarms_of_other_projects

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import is_frozen [as 別名]
def _remove_alarms_of_other_projects(self,
                                         graph,
                                         current_project_id,
                                         is_admin_project):
        """Removes wrong alarms from the graph

        Removes alarms of other tenants from the graph, In case the tenant is
        admin then project_id can also be None.

        :type graph: NXGraph
        :type current_project_id: string
        :type is_admin_project: boolean
        """
        alarms_to_remove = []
        for alarm in graph.get_vertices(query_dict=base.ALARMS_ALL_QUERY):
            if not alarm.get(VProps.PROJECT_ID, None):
                cat_filter = {VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE}
                resource_neighbors = \
                    self.entity_graph.neighbors(alarm.vertex_id,
                                                vertex_attr_filter=cat_filter)
                if len(resource_neighbors) > 0:
                    resource_proj_id = \
                        resource_neighbors[0].get(VProps.PROJECT_ID, None)
                    cond1 = is_admin_project and resource_proj_id and \
                        resource_proj_id != current_project_id
                    cond2 = not is_admin_project and \
                        (not resource_proj_id or
                         resource_proj_id != current_project_id)
                    if cond1 or cond2:
                        alarms_to_remove.append(alarm)

        if alarms_to_remove and is_frozen(graph._g):
            graph._g = graph._g.copy()

        for alarm in alarms_to_remove:
            graph.remove_vertex(alarm) 
開發者ID:openstack,項目名稱:vitrage,代碼行數:38,代碼來源:topology.py

示例5: apply_edge_attr_filter

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import is_frozen [as 別名]
def apply_edge_attr_filter(graph, edge_attr_filter):
        edges = graph._g.edges(data=True, keys=True)
        edges_to_remove = [(u, v, k) for (u, v, k, d) in edges
                           if not check_filter(d, edge_attr_filter)]

        if edges_to_remove and is_frozen(graph._g):
            graph._g = graph._g.copy()

        for source, target, key in edges_to_remove:
            graph._g.remove_edge(u=source, v=target, key=key) 
開發者ID:openstack,項目名稱:vitrage,代碼行數:12,代碼來源:networkx_algorithm.py

示例6: test_is_frozen

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import is_frozen [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

示例7: test_is_frozen

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import is_frozen [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

示例8: freeze

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import is_frozen [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

示例9: freeze

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import is_frozen [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

示例10: freeze

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import is_frozen [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.is_frozen方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。