tethne.analyze.collection module¶
Methods for analyzing GraphCollections.
algorithm | Apply a method from NetworkX to all networkx.Graph objects in the GraphCollection G. |
attachment_probability | Calculates the observed attachment probability for each node at each time-step. |
connected | Performs analysis methods from networkx.connected on each graph in the collection. |
delta | Updates a GraphCollection with deltas of a node attribute. |
node_global_closeness_centrality | Calculates global closeness centrality for node in each graph in GraphCollection G. |
- tethne.analyze.collection.algorithm(G, method, **kwargs)[source]¶
Apply a method from NetworkX to all networkx.Graph objects in the GraphCollection G.
For options, see the list of algorithms in the NetworkX documentation. Not all of these have been tested.
Parameters: G : GraphCollection
The GraphCollection to analyze. The specified method will be applied to each graph in G.
method : string
Name of a method in NetworkX to execute on graph collection.
**kwargs
A list of keyword arguments that should correspond to the parameters of the specified method.
Returns: results : dict
Indexed by element (node or edge) and graph index (e.g. date).
Raises: ValueError
If no such method exists.
Examples
Betweenness centrality: (G is a GraphCollection)
>>> from tethne.analyze import collection >>> BC = collection.algorithm(G, 'betweenness_centrality') >>> print BC[0] {1999: 0.010101651117889644, 2000: 0.0008689093723107329, 2001: 0.010504898852426189, 2002: 0.009338654511194512, 2003: 0.007519105636349891}
- tethne.analyze.collection.attachment_probability(G)[source]¶
Calculates the observed attachment probability for each node at each time-step.
Attachment probability is calculated based on the observed new edges in the next time-step. So if a node acquires new edges at time t, this will accrue to the node’s attachment probability at time t-1. Thus at a given time, one can ask whether degree and attachment probability are related.
Parameters: G : GraphCollection
Must be sliced by ‘date’. See GraphCollection.slice().
Returns: probs : dict
Keyed by index in G.graphs, and then by node.
- tethne.analyze.collection.connected(G, method, **kwargs)[source]¶
Performs analysis methods from networkx.connected on each graph in the collection.
Parameters: G : GraphCollection
The GraphCollection to analyze. The specified method will be applied to each graph in G.
method : string
Name of method in networkx.connected.
**kwargs : kwargs
Keyword arguments, passed directly to method.
Returns: results : dict
Keys are graph indices, values are output of method for that graph.
Raises: ValueError
If name is not in networkx.connected, or if no such method exists.
- tethne.analyze.collection.delta(G, attribute)[source]¶
Updates a GraphCollection with deltas of a node attribute.
Parameters: G : GraphCollection
attribute : str
Name of a node attribute in G.
Returns: deltas : dict
- tethne.analyze.collection.node_global_closeness_centrality(G, node)[source]¶
Calculates global closeness centrality for node in each graph in GraphCollection G.