summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael-E-Rose <Michael.Ernst.Rose@gmail.com>2016-04-16 22:29:50 +0200
committerMichael-E-Rose <Michael.Ernst.Rose@gmail.com>2016-04-16 22:29:50 +0200
commitfb32612170fda09772f2e15f8406fa7931694b0e (patch)
treeb9a0c0563e324131354ffb22eb3998de5ff14b90
parente15901bd40201661008222397c8d58d06292ed2c (diff)
downloadnetworkx-fb32612170fda09772f2e15f8406fa7931694b0e.tar.gz
Apply PEP8 in code
-rw-r--r--networkx/algorithms/components/attracting.py10
-rw-r--r--networkx/algorithms/components/biconnected.py23
2 files changed, 18 insertions, 15 deletions
diff --git a/networkx/algorithms/components/attracting.py b/networkx/algorithms/components/attracting.py
index 9351ed00..ae805903 100644
--- a/networkx/algorithms/components/attracting.py
+++ b/networkx/algorithms/components/attracting.py
@@ -11,12 +11,13 @@
import networkx as nx
from networkx.utils.decorators import not_implemented_for
-__all__ = ['number_attracting_components',
+__all__ = ['number_attracting_components',
'attracting_components',
- 'is_attracting_component',
+ 'is_attracting_component',
'attracting_component_subgraphs',
]
+
@not_implemented_for('undirected')
def attracting_components(G):
"""Generates a list of attracting components in `G`.
@@ -47,7 +48,7 @@ def attracting_components(G):
See Also
--------
number_attracting_components
- is_attracting_component
+ is_attracting_component
attracting_component_subgraphs
"""
@@ -57,6 +58,7 @@ def attracting_components(G):
if cG.out_degree(n) == 0:
yield scc[n]
+
@not_implemented_for('undirected')
def number_attracting_components(G):
"""Returns the number of attracting components in `G`.
@@ -136,7 +138,7 @@ def attracting_component_subgraphs(G, copy=True):
A list of node-induced subgraphs of the attracting components of `G`.
copy : bool
- If copy is True, graph, node, and edge attributes are copied to the
+ If copy is True, graph, node, and edge attributes are copied to the
subgraphs.
Raises
diff --git a/networkx/algorithms/components/biconnected.py b/networkx/algorithms/components/biconnected.py
index 6bd6aff2..53a96caf 100644
--- a/networkx/algorithms/components/biconnected.py
+++ b/networkx/algorithms/components/biconnected.py
@@ -89,7 +89,7 @@ def is_biconnected(G):
"""
bcc = list(biconnected_components(G))
- if not bcc: # No bicomponents (it could be an empty graph)
+ if not bcc: # No bicomponents (it could be an empty graph)
return False
return len(bcc[0]) == len(G)
@@ -254,6 +254,7 @@ def biconnected_components(G):
for comp in _biconnected_dfs(G, components=True):
yield set(chain.from_iterable(comp))
+
@not_implemented_for('directed')
def biconnected_component_subgraphs(G, copy=True):
"""Return a generator of graphs, one graph for each biconnected component
@@ -427,8 +428,8 @@ def _biconnected_dfs(G, components=True):
for start in G:
if start in visited:
continue
- discovery = {start:0} # "time" of first discovery of node during search
- low = {start:0}
+ discovery = {start: 0} # time of first discovery of node during search
+ low = {start: 0}
root_children = 0
visited.add(start)
edge_stack = []
@@ -440,31 +441,31 @@ def _biconnected_dfs(G, components=True):
if grandparent == child:
continue
if child in visited:
- if discovery[child] <= discovery[parent]: # back edge
- low[parent] = min(low[parent],discovery[child])
+ if discovery[child] <= discovery[parent]: # back edge
+ low[parent] = min(low[parent], discovery[child])
if components:
- edge_stack.append((parent,child))
+ edge_stack.append((parent, child))
else:
low[child] = discovery[child] = len(discovery)
visited.add(child)
stack.append((parent, child, iter(G[child])))
if components:
- edge_stack.append((parent,child))
+ edge_stack.append((parent, child))
except StopIteration:
stack.pop()
if len(stack) > 1:
if low[parent] >= discovery[grandparent]:
if components:
- ind = edge_stack.index((grandparent,parent))
+ ind = edge_stack.index((grandparent, parent))
yield edge_stack[ind:]
- edge_stack=edge_stack[:ind]
+ edge_stack = edge_stack[:ind]
else:
yield grandparent
low[grandparent] = min(low[parent], low[grandparent])
- elif stack: # length 1 so grandparent is root
+ elif stack: # length 1 so grandparent is root
root_children += 1
if components:
- ind = edge_stack.index((grandparent,parent))
+ ind = edge_stack.index((grandparent, parent))
yield edge_stack[ind:]
if not components:
# root node is articulation point if it has more than 1 child