本文整理汇总了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
点赞 6
# 需要导入模块: 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,
示例2: is_frozen
点赞 6
# 需要导入模块: 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,
示例3: is_frozen
点赞 6
# 需要导入模块: 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,
示例4: _remove_alarms_of_other_projects
点赞 5
# 需要导入模块: 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,
示例5: apply_edge_attr_filter
点赞 5
# 需要导入模块: 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,
示例6: test_is_frozen
点赞 5
# 需要导入模块: 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,
示例7: test_is_frozen
点赞 5
# 需要导入模块: 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,
示例8: freeze
点赞 4
# 需要导入模块: 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,
示例9: freeze
点赞 4
# 需要导入模块: 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,
示例10: freeze
点赞 4
# 需要导入模块: 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,
注:本文中的networkx.is_frozen方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。