summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMridul Seth <seth.mridul@gmail.com>2015-06-27 20:26:09 +0530
committerMridul Seth <seth.mridul@gmail.com>2015-06-27 20:26:09 +0530
commit5d44d9659984d622ef00708e3fbb65c8ae8d2a12 (patch)
tree02a2afa6eba95e66f123d136dbb8ccee35545b26
parent6862ab0dd7d0bc07c2ea3a9351fd30b89268df8c (diff)
downloadnetworkx-5d44d9659984d622ef00708e3fbb65c8ae8d2a12.tar.gz
Remove commented out code
-rw-r--r--networkx/algorithms/approximation/kcomponents.py42
-rw-r--r--networkx/classes/graph.py88
2 files changed, 6 insertions, 124 deletions
diff --git a/networkx/algorithms/approximation/kcomponents.py b/networkx/algorithms/approximation/kcomponents.py
index da4608db..f7b8a49d 100644
--- a/networkx/algorithms/approximation/kcomponents.py
+++ b/networkx/algorithms/approximation/kcomponents.py
@@ -186,7 +186,7 @@ def _cliques_heuristic(G, H, k, min_density):
sh_cnumber = nx.core_number(SH)
sh_deg = dict(SH.degree())
min_deg = min(sh_deg.values())
- SH.remove_nodes_from((n for n, d in sh_deg.items() if d == min_deg))
+ SH.remove_nodes_from(n for n, d in sh_deg.items() if d == min_deg)
SG = nx.k_core(G.subgraph(SH), k)
else:
yield SG
@@ -236,31 +236,6 @@ class _AntiGraph(nx.Graph):
return dict((node, all_edge_dict) for node in
set(self.adj) - set(self.adj[n]) - set([n]))
- # def neighbors(self, n):
- # """Return a list of the nodes connected to the node n in
- # the dense graph.
-
- # Parameters
- # ----------
- # n : node
- # A node in the graph
-
- # Returns
- # -------
- # nlist : list
- # A list of nodes that are adjacent to n.
-
- # Raises
- # ------
- # NetworkXError
- # If the node n is not in the graph.
-
- # """
- # try:
- # return list(set(self.adj) - set(self.adj[n]) - set([n]))
- # except KeyError:
- # raise NetworkXError("The node %s is not in the graph."%(n,))
-
def neighbors(self, n):
"""Return an iterator over all neighbors of node n in the
dense graph.
@@ -271,16 +246,8 @@ class _AntiGraph(nx.Graph):
except KeyError:
raise NetworkXError("The node %s is not in the graph."%(n,))
- # def degree(self, nbunch=None, weight=None):
- # """Return the degree of a node or nodes in the dense graph.
- # """
- # if nbunch in self: # return a single node
- # return next(self.degree_iter(nbunch,weight))[1]
- # else: # return a dict
- # return dict(self.degree_iter(nbunch,weight))
-
def degree(self, nbunch=None, weight=None):
- """Return an iterator for (node, degree) in the dense graph.
+ """Return an iterator for (node, degree) and degree for single node.
The node degree is the number of edges adjacent to the node.
@@ -297,6 +264,8 @@ class _AntiGraph(nx.Graph):
Returns
-------
+ deg:
+ Degree of the node, if a single node is passed as argument.
nd_iter : an iterator
The iterator returns two-tuples of (node, degree).
@@ -315,7 +284,8 @@ class _AntiGraph(nx.Graph):
"""
if nbunch in self:
- nbrs = {v: self.all_edge_dict for v in set(self.adj) - set(self.adj[nbunch]) - set([nbunch])}
+ nbrs = {v: self.all_edge_dict for v in set(self.adj) - \
+ set(self.adj[nbunch]) - set([nbunch])}
if weight is None:
return len(nbrs) + (nbunch in nbrs)
return sum((nbrs[nbr].get(weight, 1) for nbr in nbrs)) + \
diff --git a/networkx/classes/graph.py b/networkx/classes/graph.py
index 953d6f23..9967953e 100644
--- a/networkx/classes/graph.py
+++ b/networkx/classes/graph.py
@@ -1279,94 +1279,6 @@ class Graph(object):
(nbrs[n].get(weight, 1) if n in nbrs else 0))
return d_iter()
- # def degree(self, nbunch=None, weight=None):
- # """Return the degree of a node or nodes.
-
- # The node degree is the number of edges adjacent to that node.
-
- # Parameters
- # ----------
- # nbunch : iterable container, optional (default=all nodes)
- # A container of nodes. The container will be iterated
- # through once.
-
- # weight : string or None, optional (default=None)
- # The edge attribute that holds the numerical value used
- # as a weight. If None, then each edge has weight 1.
- # The degree is the sum of the edge weights adjacent to the node.
-
- # Returns
- # -------
- # nd : dictionary, or number
- # A dictionary with nodes as keys and degree as values or
- # a number if a single node is specified.
-
- # Examples
- # --------
- # >>> G = nx.Graph() # or DiGraph, MultiGraph, MultiDiGraph, etc
- # >>> G.add_path([0,1,2,3])
- # >>> G.degree(0)
- # 1
- # >>> G.degree([0,1])
- # {0: 1, 1: 2}
- # >>> list(G.degree([0,1]).values())
- # [1, 2]
-
- # """
- # if nbunch in self: # return a single node
- # return next(self.degree_iter(nbunch, weight))[1]
- # else: # return a dict
- # return dict(self.degree_iter(nbunch, weight))
-
- # def degree_iter(self, nbunch=None, weight=None):
- # """Return an iterator for (node, degree).
-
- # The node degree is the number of edges adjacent to the node.
-
- # Parameters
- # ----------
- # nbunch : iterable container, optional (default=all nodes)
- # A container of nodes. The container will be iterated
- # through once.
-
- # weight : string or None, optional (default=None)
- # The edge attribute that holds the numerical value used
- # as a weight. If None, then each edge has weight 1.
- # The degree is the sum of the edge weights adjacent to the node.
-
- # Returns
- # -------
- # nd_iter : an iterator
- # The iterator returns two-tuples of (node, degree).
-
- # See Also
- # --------
- # degree
-
- # Examples
- # --------
- # >>> G = nx.Graph() # or DiGraph, MultiGraph, MultiDiGraph, etc
- # >>> G.add_path([0,1,2,3])
- # >>> list(G.degree_iter(0)) # node 0 with degree 1
- # [(0, 1)]
- # >>> list(G.degree_iter([0,1]))
- # [(0, 1), (1, 2)]
-
- # """
- # if nbunch is None:
- # nodes_nbrs = self.adj.items()
- # else:
- # nodes_nbrs = ((n, self.adj[n]) for n in self.nbunch_iter(nbunch))
-
- # if weight is None:
- # for n, nbrs in nodes_nbrs:
- # yield (n, len(nbrs) + (n in nbrs)) # return tuple (n,degree)
- # else:
- # # edge weighted graph - degree is sum of nbr edge weights
- # for n, nbrs in nodes_nbrs:
- # yield (n, sum((nbrs[nbr].get(weight, 1) for nbr in nbrs)) +
- # (n in nbrs and nbrs[n].get(weight, 1)))
-
def clear(self):
"""Remove all nodes and edges from the graph.