The average degree connectivity is the average nearest neighbor degree of
nodes with degree k. For weighted graphs, an analogous measure can
be computed using the weighted average neighbors degree defined in
[1]_, for a node i, as
where s_i is the weighted degree of node i,
w_{ij} is the weight of the edge that links i and j,
and N(i) are the neighbors of node i.
Parameters:
G (NetworkX graph) –
source ("in"|"out"|"in+out" (default:"in+out")) – Directed graphs only. Use “in”- or “out”-degree for source node.
target ("in"|"out"|"in+out" (default:"in+out") – Directed graphs only. Use “in”- or “out”-degree for target node.
nodes (list or iterable (optional)) – Compute neighbor connectivity for these nodes. The default is all
nodes.
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.
Returns:
d – A dictionary keyed by degree k with the value of average connectivity.
Return type:
dict
Raises:
NetworkXError – If either source or target are not one of ‘in’,
‘out’, or ‘in+out’.
If either source or target is passed for an undirected graph.
Purpose: To compute the shortest path distance
between nodes in a graph (may just need to sample the path)
Pseudocode:
1) Generate x samples of nodes in the graph as the sources and as the targets
2) Make sure the two nodes are not the same
3) Compute the shortest path and add to the list
4) Compute the mean and standard deviation
5) Plot a histogram if requested
local clustering: theoretically the fraction of traingles that actually exist /
all possible traingles in its neighborhood
How it is computed:
1) choose random node
2) choose 2 neighbors at random
3) check if traingle (if yes increment traingle counter)
4) Repeat and compute number with triangle_counter/ trials
Compute the eigenvector centrality for the graph G.
Eigenvector centrality computes the centrality for a node based on the
centrality of its neighbors. The eigenvector centrality for node $i$ is
\[Ax = \lambda x\]
where $A$ is the adjacency matrix of the graph G with eigenvalue $lambda$.
By virtue of the Perron–Frobenius theorem, there is a unique and positive
solution if $lambda$ is the largest eigenvalue associated with the
eigenvector of the adjacency matrix $A$ ([2]).
Parameters:
G (graph) – A networkx graph
weight (None or string, optional (default=None)) – The name of the edge attribute used as weight.
If None, all edge weights are considered equal.
In this measure the weight is interpreted as the connection strength.
max_iter (integer, optional (default=100)) – Maximum number of iterations in power method.
tol (float, optional (default=1.0e-6)) – Relative accuracy for eigenvalues (stopping criterion).
The default value of 0 implies machine precision.
Returns:
nodes – Dictionary of nodes with eigenvector centrality as the value.
This algorithm uses the SciPy sparse eigenvalue solver (ARPACK) to
find the largest eigenvalue/eigenvector pair.
For directed graphs this is “left” eigenvector centrality which corresponds
to the in-edges in the graph. For out-edges eigenvector centrality
first reverse the graph with G.reverse().
Raises:
NetworkXPointlessConcept – If the graph G is the null graph.
clique is just subset of vertices group where every
vertex in group is connected (subgraph induced is complete)
Maximal clique = clique that cannot be extended by including one or more adjacent vertex
(aka not subset of larger clique)
Maximum clique = clique of the largest size in a graph
clique number = number of vertices in a maxium clique
A dictionary with nodes as keys and positions as values.
If not specified a spring layout positioning will be computed.
See networkx.drawing.layout for functions that
compute node positions.
arrowsbool or None, optional (default=None)
If None, directed graphs draw arrowheads with
~matplotlib.patches.FancyArrowPatch, while undirected graphs draw edges
via ~matplotlib.collections.LineCollection for speed.
If True, draw arrowheads with FancyArrowPatches (bendable and stylish).
If False, draw edges using LineCollection (linear and fast).
For directed graphs, if True draw arrowheads.
Note: Arrows will be the same color as edges.
arrowstylestr (default=’-|>’ for directed graphs)
For directed graphs, choose the style of the arrowsheads.
For undirected graphs default to ‘-’
See matplotlib.patches.ArrowStyle for more options.
arrowsizeint or list (default=10)
For directed graphs, choose the size of the arrow head’s length and
width. A list of values can be passed in to assign a different size for arrow head’s length and width.
See matplotlib.patches.FancyArrowPatch for attribute mutation_scale
for more info.
with_labelsbool (default=True)
Set to True to draw labels on the nodes.
axMatplotlib Axes object, optional
Draw the graph in the specified Matplotlib axes.
nodelistlist (default=list(G))
Draw only specified nodes
edgelistlist (default=list(G.edges()))
Draw only specified edges
node_sizescalar or array (default=300)
Size of nodes. If an array is specified it must be the
same length as nodelist.
node_colorcolor or array of colors (default=’#1f78b4’)
Node color. Can be a single color or a sequence of colors with the same
length as nodelist. Color can be string or rgb (or rgba) tuple of
floats from 0-1. If numeric values are specified they will be
mapped to colors using the cmap and vmin,vmax parameters. See
matplotlib.scatter for more details.
node_shapestring (default=’o’)
The shape of the node. Specification is as matplotlib.scatter
marker, one of ‘so^>v<dph8’.
alphafloat or None (default=None)
The node and edge transparency
cmapMatplotlib colormap, optional
Colormap for mapping intensities of nodes
vmin,vmaxfloat, optional
Minimum and maximum for node colormap scaling
linewidthsscalar or sequence (default=1.0)
Line width of symbol border
widthfloat or array of floats (default=1.0)
Line width of edges
edge_colorcolor or array of colors (default=’k’)
Edge color. Can be a single color or a sequence of colors with the same
length as edgelist. Color can be string or rgb (or rgba) tuple of
floats from 0-1. If numeric values are specified they will be
mapped to colors using the edge_cmap and edge_vmin,edge_vmax parameters.
edge_cmapMatplotlib colormap, optional
Colormap for mapping intensities of edges
edge_vmin,edge_vmaxfloats, optional
Minimum and maximum for edge colormap scaling
stylestring (default=solid line)
Edge line style e.g.: ‘-’, ‘–’, ‘-.’, ‘:’
or words like ‘solid’ or ‘dashed’.
(See matplotlib.patches.FancyArrowPatch: linestyle)
labelsdictionary (default=None)
Node labels in a dictionary of text labels keyed by node
font_sizeint (default=12 for nodes, 10 for edges)
Font size for text labels
font_colorstring (default=’k’ black)
Font color string
font_weightstring (default=’normal’)
Font weight
font_familystring (default=’sans-serif’)
Font family
labelstring, optional
Label for graph legend
kwdsoptional keywords
See networkx.draw_networkx_nodes(), networkx.draw_networkx_edges(), and
networkx.draw_networkx_labels() for a description of optional keywords.
Attempt to create a valid degree sequence of length n using
specified function sfunction(n,**kwds).
Parameters:
n (int) – Length of degree sequence = number of nodes
sfunction (function) – Function which returns a list of n real or integer values.
Called as “sfunction(n,**kwds)”.
max_tries (int) – Max number of attempts at creating valid degree sequence.
Notes
Repeatedly create a degree sequence by calling sfunction(n,**kwds)
until achieving a valid degree sequence. If unsuccessful after
max_tries attempts, raise an exception.
For examples of sfunctions that return sequences of random numbers,
see networkx.Utils.
Returns an undirected graph using the duplication-divergence model.
with probability p copies the edges of a node
with probability (1-p makes random edge)
Returns an undirected graph using the duplication-divergence model.
with probability p copies the edges of a node
with probability (1-p makes random edge)
graph_tools.null_models.watts_strogatz_graph_smallworld_random_location(n, m, p)[source]