apply if weight='weight'

• ## sage/graphs/digraph.py

# HG changeset patch
# User Karl-Dieter Crisman <kcrisman@gmail.com>
# Date 1341316749 -3600
diff --git a/sage/graphs/digraph.py b/sage/graphs/digraph.py
 a ...      g.subgraph(component).plot() The same methods works for strongly connected components :: sage: for component in g.strongly_connected_components(): ...      g.subgraph(component).plot() - implementation -- Use the default Cython implementation (implementation = default), the default NetworkX library (implementation = "NetworkX") or the recursive NetworkX implementation (implementation = "recursive") implementation (implementation = "recursive") .. SEEALSO:: .. note:: There is a recursive version of this in NetworkX, it used to have problems in earlier versions but they have since been fixed:: have problems in earlier versions but they have since been fixed:: sage: import networkx sage: D = DiGraph({ 0:[1,2,3], 4:[2,5], 1:, 2:, 3:,
diff --git a/sage/graphs/generic_graph.py b/sage/graphs/generic_graph.py
 a The clustering coefficient of a graph is the fraction of possible triangles that are triangles, c_i = triangles_i / (k_i\*(k_i-1)/2) where k_i is the degree of vertex i, . A (k_i\*(k_i-1)/2) where k_i is the degree of vertex i, [HSSNX]_. A coefficient for the whole graph is the average of the c_i. Transitivity is the fraction of all possible triangles which are triangles, T = 3\*triangles/triads, [HSSNX]_. def clustering_average(self): r""" Returns the average clustering coefficient. The clustering coefficient of a graph is the fraction of possible triangles that are triangles, c_i = triangles_i / (k_i\*(k_i-1)/2) where k_i is the degree of vertex i, . A (k_i\*(k_i-1)/2) where k_i is the degree of vertex i, [NTX]_. A coefficient for the whole graph is the average of the c_i. Transitivity is the fraction of all possible triangles which are triangles, T = 3\*triangles/triads, . triangles, T = 3\*triangles/triads, [NTX]_. REFERENCE: -  Aric Hagberg, Dan Schult and Pieter Swart. NetworkX .. [NTX] Aric Hagberg, Dan Schult and Pieter Swart. NetworkX documentation. [Online] Available: https://networkx.lanl.gov/reference/networkx/ EXAMPLES:: EXAMPLES:: sage: (graphs.FruchtGraph()).clustering_average() 0.25 """ def clustering_coeff(self, nodes=None, weight=False, return_vertex_weights=True): r""" Returns the clustering coefficient for each vertex in nodes as Returns the clustering coefficient for each vertex in nodes as a dictionary keyed by vertex. For an unweighted graph, the clustering coefficient of a node i is the fraction of possible triangles containing i that exist. c_i = 2\*T(i) / (k_i\*(k_i-1)) where T(i) the number exist. \frac{2 T(i)}{k_i (k_i-1)} where T(i) the number of triangles through i and k_i is the degree of vertex i . [NX]_. For weighted graphs the clustering is defined as the geometric average of the subgraph edge weights , normalized by the average of the subgraph edge weights [NX]_, normalized by the maximum weight in the network. The value of c_i is assigned to 0 if k_i < 2. A coefficient for the whole graph is the average of the c_i. Transitivity is the fraction of all possible triangles which are triangles, T = 3\*triangles/triads, . triangles, T = 3\*triangles/triads, [NX]_. INPUT: - nodes - the vertices to inspect (default None returns data on all vertices in graph) - weight - string or boolean default is False. If it is - weight - string or boolean (default is False). If it is a string it used the indicated edge property as weight. weight = True is equivalent to weight = weight weight = True is equivalent to weight = 'weight' - return_vertex_weights is a boolean ensuring backwards compatibility with deprecated features of NetworkX 1.2. It REFERENCE: -  Aric Hagberg, Dan Schult and Pieter Swart. NetworkX .. [NX] Aric Hagberg, Dan Schult and Pieter Swart. NetworkX documentation. [Online] Available: https://networkx.lanl.gov/reference/networkx/ The clustering coefficient of a graph is the fraction of possible triangles that are triangles, c_i = triangles_i / (k_i\*(k_i-1)/2) where k_i is the degree of vertex i, . A (k_i\*(k_i-1)/2) where k_i is the degree of vertex i, _. A coefficient for the whole graph is the average of the c_i. Transitivity is the fraction of all possible triangles which are triangles, T = 3\*triangles/triads, . triangles, T = 3\*triangles/triads, _. REFERENCE: