AP greedy method for structural hole spanners detection.
Returns top k nodes as structural hole spanners,
Algorithm 2 of [1]_
Parameters:
G (easygraph.Graph) – An undirected graph.
k (int) – top - k structural hole spanners
c (float, optional (default : 1.0)) – To define zeta: zeta = c * (n*n*n), and zeta is the large
value assigned as the shortest distance of two unreachable
vertices.
Default is 1.
weight (String or None, optional (default : 'weight')) – Key for edge weight. None if not concerning about edge weight.
Returns:
AP_greedy – The list of each top-k structural hole spanners.
Return type:
list
Examples
Returns the top k nodes as structural hole spanners, using AP_greedy.
>>> AP_greedy(G,... k=3,# To find top three structural holes spanners.... c=1.0,# To define zeta: zeta = c * (n*n*n), and zeta is the large value assigned as the shortest distance of two unreachable vertices.... weight='weight')
Common greedy method for structural hole spanners detection.
Returns top k nodes as structural hole spanners,
Algorithm 1 of [1]_
Parameters:
G (easygraph.Graph) – An undirected graph.
k (int) – top - k structural hole spanners
c (float, optional (default : 1.0)) – To define zeta: zeta = c * (n*n*n), and zeta is the large
value assigned as the shortest distance of two unreachable
vertices.
Default is 1.
weight (String or None, optional (default : 'weight')) – Key for edge weight. None if not concerning about edge weight.
Returns:
common_greedy – The list of each top-k structural hole spanners.
Returns the top k nodes as structural hole spanners, using common_greedy.
>>> common_greedy(G,... k=3,# To find top three structural holes spanners.... c=1.0,# To define zeta: zeta = c * (n*n*n), and zeta is the large value assigned as the shortest distance of two unreachable vertices.... weight='weight')
Structural hole spanners detection via HAM method.
Using HAM [1]_ to jointly detect SHS and communities.
Parameters:
G (easygraph.Graph) – An undirected graph.
k (int) – top - k structural hole spanners
c (int) – the number of communities
ground_truth_labels (list of lists) – The label of each node’s community.
Returns:
top_k_nodes (list) – The top-k structural hole spanners.
SH_score (dict) – The structural hole spanners score for each node, given by HAM.
cmnt_labels (dict) – The communities label of each node.
Examples
>>> get_structural_holes_HAM(G,... k=2,# To find top two structural holes spanners.... c=2,... ground_truth_labels=[[0],[0],[1],[0],[1]]# The ground truth labels for each node - community detection result, for example.... )
Structural hole spanners detection via HIS method.
Both HIS and MaxD are methods in [1]_.
The authors developed these two methods to find the structural holes spanners,
based on theory of information diffusion.
Returns the value of S, I, H ,defined in HIS of [1], of each node in the graph.
Note that H quantifies the possibility that a node is a structural hole spanner.
To use HIS method, you should provide the community detection result as parameter.
Parameters:
C (list of frozenset) – Each frozenset denotes a community of nodes.
epsilon (float) – The threshold value.
weight (string, optional (default : 'weight')) – The key for edge weight.
Structural hole spanners detection via MaxD method.
Both HIS and MaxD are methods in [1]_.
The authors developed these two methods to find the structural holes spanners,
based on theory of information diffusion.
Parameters:
k (int) – Top-k structural hole spanners
C (list of frozenset) – Each frozenset denotes a community of nodes.
>>> get_structural_holes_MaxD(G,... k=5,# To find top five structural holes spanners.... C=[frozenset([1,2,3]),frozenset([4,5,6])]# Two communities... )
S (list of int) – A list of nodes which are structural hole spanners.
C (list of list) – Each list includes the nodes in one community.
model (string) – Propagation Model. Should be IC or LT.
variant (bool, default is False) – Whether returns variant SHII ml_metrics or not.
variant SHII = # of the influenced outsider / # of the influenced insiders
SHII = # of the influenced outsiders / # of the total influenced nodes
seedRatio (float, default is 0.05) – # of sampled seeds / # of nodes of the community that the given SHS belongs to.
randSeedIter (int, default is 10) – How many iterations to sample seeds.
countIterations (int default is 100) – Number of monte carlo simulations to be used.
Directed (bool, default is True) – Whether the graph is directed or not.
Burt’s metric - Constraint.
:param G:
:type G: easygraph.Graph
:param nodes: The nodes you want to calculate. If None, all nodes in G will be calculated.
:type nodes: list of nodes or None, optional (default : None)
:param weight: The key for edge weight. If None, G will be regarded as unweighted graph.
:type weight: string or None, optional (default : None)
:param workers: The number of workers calculating (default: None).
None if not using only one worker.
Returns:
constraint – The Constraint of node in nodes.
Return type:
dict
Examples
>>> constraint(G,... nodes=[1,2,3],# Compute the Constraint of some nodes. The default is None for all nodes in G.... weight='weight',# The weight key of the graph. The default is None for unweighted graph.... n_workers=4# Parallel computing on four workers. The default is None for serial computing.... )
Burt’s metric - Effective Size.
:param G:
:type G: easygraph.Graph or easygraph.DiGraph
:param nodes: The nodes you want to calculate. If None, all nodes in G will be calculated.
:type nodes: list of nodes or None, optional (default : None)
:param weight: The key for edge weight. If None, G will be regarded as unweighted graph.
:type weight: string or None, optional (default : None)
Returns:
effective_size – The Effective Size of node in nodes.
Return type:
dict
Examples
>>> effective_size(G,... nodes=[1,2,3],# Compute the Effective Size of some nodes. The default is None for all nodes in G.... weight='weight'# The weight key of the graph. The default is None for unweighted graph.... )
Burt’s metric - Efficiency.
:param G:
:type G: easygraph.Graph
:param nodes: The nodes you want to calculate. If None, all nodes in G will be calculated.
:type nodes: list of nodes or None, optional (default : None)
:param weight: The key for edge weight. If None, G will be regarded as unweighted graph.
:type weight: string or None, optional (default : None)
Returns:
efficiency – The Efficiency of node in nodes.
Return type:
dict
Examples
>>> efficiency(G,... nodes=[1,2,3],# Compute the Efficiency of some nodes. The default is None for all nodes in G.... weight='weight'# The weight key of the graph. The default is None for unweighted graph.... )
S (list of int) – A list of nodes which are structural hole spanners.
C (list of list) – Each list includes the nodes in one community.
model (string) – Propagation Model. Should be IC or LT.
variant (bool, default is False) – Whether returns variant SHII ml_metrics or not.
variant SHII = # of the influenced outsider / # of the influenced insiders
SHII = # of the influenced outsiders / # of the total influenced nodes
seedRatio (float, default is 0.05) – # of sampled seeds / # of nodes of the community that the given SHS belongs to.
randSeedIter (int, default is 10) – How many iterations to sample seeds.
countIterations (int default is 100) – Number of monte carlo simulations to be used.
Directed (bool, default is True) – Whether the graph is directed or not.