Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix some warnings
  • Loading branch information
jarrodmillman committed Oct 12, 2019
1 parent 67bb8de commit b007158
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
3 changes: 2 additions & 1 deletion networkx/algorithms/bipartite/basic.py
Expand Up @@ -11,6 +11,7 @@
# All rights reserved.
# BSD license.
import networkx as nx
from networkx.algorithms.components import connected_components
__author__ = """\n""".join(['Jordi Torrents <jtorrents@milnou.net>',
'Aric Hagberg <aric.hagberg@gmail.com>'])
__all__ = ['is_bipartite',
Expand Down Expand Up @@ -134,7 +135,7 @@ def is_bipartite_node_set(G, nodes):
disconnected graphs.
"""
S = set(nodes)
for CC in nx.connected_component_subgraphs(G):
for CC in (G.subgraph(c).copy() for c in connected_components(G)):
X, Y = sets(CC)
if not ((X.issubset(S) and Y.isdisjoint(S)) or
(Y.issubset(S) and X.isdisjoint(S))):
Expand Down
3 changes: 2 additions & 1 deletion networkx/algorithms/chordal.py
Expand Up @@ -9,6 +9,7 @@
import sys

import networkx as nx
from networkx.algorithms.components import connected_components
from networkx.utils import arbitrary_element, not_implemented_for

__authors__ = "\n".join(['Jesus Cerquides <cerquide@iiia.csic.es>',
Expand Down Expand Up @@ -199,7 +200,7 @@ def chordal_graph_cliques(G):
raise nx.NetworkXError("Input graph is not chordal.")

cliques = set()
for C in nx.connected.connected_component_subgraphs(G):
for C in (G.subgraph(c).copy() for c in connected_components(G)):
cliques |= _connected_chordal_graph_cliques(C)

return cliques
Expand Down
2 changes: 1 addition & 1 deletion networkx/algorithms/dag.py
Expand Up @@ -20,7 +20,7 @@
"""

from collections import defaultdict, deque
from fractions import gcd
from math import gcd
from functools import partial
from itertools import chain
from itertools import product
Expand Down
3 changes: 2 additions & 1 deletion networkx/algorithms/shortest_paths/generic.py
Expand Up @@ -16,6 +16,7 @@
"""

import networkx as nx
from networkx.algorithms.components import connected_components

__all__ = ['shortest_path', 'all_shortest_paths',
'shortest_path_length', 'average_shortest_path_length',
Expand Down Expand Up @@ -369,7 +370,7 @@ def average_shortest_path_length(G, weight=None, method=None):
length for each component
>>> G = nx.Graph([(1, 2), (3, 4)])
>>> for C in nx.connected_component_subgraphs(G):
>>> for C in (G.subgraph(c).copy() for c in connected_components(G)):
... print(nx.average_shortest_path_length(C))
1.0
1.0
Expand Down
12 changes: 6 additions & 6 deletions networkx/classes/tests/test_graph.py
Expand Up @@ -13,21 +13,21 @@ def test_deprecated():
assert G.node == {0: {}, 1: {}, 2: {}}

G = nx.DiGraph()
G.add_path([3, 4])
nx.add_path(G, [3, 4])
assert G.adj == {3: {4: {}}, 4: {}}

G = nx.DiGraph()
G.add_cycle([3, 4, 5])
nx.add_cycle(G, [3, 4, 5])
assert G.adj == {3: {4: {}}, 4: {5: {}}, 5: {3: {}}}

G = nx.DiGraph()
G.add_star([3, 4, 5])
nx.add_star(G, [3, 4, 5])
assert G.adj == {3: {4: {}, 5: {}}, 4: {}, 5: {}}

G = nx.DiGraph([(0, 0), (0, 1), (1, 2)])
assert G.number_of_selfloops() == 1
assert list(G.nodes_with_selfloops()) == [0]
assert list(G.selfloop_edges()) == [(0, 0)]
assert nx.number_of_selfloops(G) == 1
assert list(nx.nodes_with_selfloops(G)) == [0]
assert list(nx.selfloop_edges(G)) == [(0, 0)]


class BaseGraphTester(object):
Expand Down

0 comments on commit b007158

Please sign in to comment.