NetworkX
2.2
  • Install
  • Tutorial
  • Reference
    • Introduction
    • Graph types
    • Algorithms
      • Approximations and Heuristics
      • Assortativity
      • Bipartite
      • Boundary
      • Bridges
      • Centrality
      • Chains
      • Chordal
      • Clique
      • Clustering
      • Coloring
      • Communicability
      • Communities
      • Components
      • Connectivity
      • Cores
      • Covering
      • Cycles
      • Cuts
      • Directed Acyclic Graphs
      • Dispersion
      • Distance Measures
      • Distance-Regular Graphs
      • Dominance
      • Dominating Sets
      • Efficiency
      • Eulerian
      • Flows
      • Graphical degree sequence
      • Hierarchy
      • Hybrid
      • Isolates
      • Isomorphism
      • Link Analysis
      • Link Prediction
        • networkx.algorithms.link_prediction.resource_allocation_index
        • networkx.algorithms.link_prediction.jaccard_coefficient
        • networkx.algorithms.link_prediction.adamic_adar_index
        • networkx.algorithms.link_prediction.preferential_attachment
        • networkx.algorithms.link_prediction.cn_soundarajan_hopcroft
        • networkx.algorithms.link_prediction.ra_index_soundarajan_hopcroft
        • networkx.algorithms.link_prediction.within_inter_cluster
      • Lowest Common Ancestor
      • Matching
      • Minors
      • Maximal independent set
      • Node Classification
      • Operators
      • Planarity
      • Reciprocity
      • Rich Club
      • Shortest Paths
      • Similarity Measures
      • Simple Paths
      • Similarity Measures
      • s metric
      • Sparsifiers
      • Structural holes
      • Swap
      • Tournament
      • Traversal
      • Tree
      • Triads
      • Vitality
      • Voronoi cells
      • Wiener index
    • Functions
    • Graph generators
    • Linear algebra
    • Converting to and from other data formats
    • Relabeling nodes
    • Reading and writing graphs
    • Drawing
    • Randomness
    • Exceptions
    • Utilities
    • Glossary
  • Developer Guide
  • Release Log
  • License
  • Credits
  • Citing
  • Bibliography
  • Examples
NetworkX
  • Docs »
  • Reference »
  • Algorithms »
  • Link Prediction »
  • networkx.algorithms.link_prediction.within_inter_cluster

networkx.algorithms.link_prediction.within_inter_cluster¶

within_inter_cluster(G, ebunch=None, delta=0.001, community='community')[source]¶

Compute the ratio of within- and inter-cluster common neighbors of all node pairs in ebunch.

For two nodes u and v, if a common neighbor w belongs to the same community as them, w is considered as within-cluster common neighbor of u and v. Otherwise, it is considered as inter-cluster common neighbor of u and v. The ratio between the size of the set of within- and inter-cluster common neighbors is defined as the WIC measure. [1]

Parameters:
  • G (graph) – A NetworkX undirected graph.
  • ebunch (iterable of node pairs, optional (default = None)) – The WIC measure will be computed for each pair of nodes given in the iterable. The pairs must be given as 2-tuples (u, v) where u and v are nodes in the graph. If ebunch is None then all non-existent edges in the graph will be used. Default value: None.
  • delta (float, optional (default = 0.001)) – Value to prevent division by zero in case there is no inter-cluster common neighbor between two nodes. See [1] for details. Default value: 0.001.
  • community (string, optional (default = ‘community’)) – Nodes attribute name containing the community information. G[u][community] identifies which community u belongs to. Each node belongs to at most one community. Default value: ‘community’.
Returns:

piter – An iterator of 3-tuples in the form (u, v, p) where (u, v) is a pair of nodes and p is their WIC measure.

Return type:

iterator

Examples

>>> import networkx as nx
>>> G = nx.Graph()
>>> G.add_edges_from([(0, 1), (0, 2), (0, 3), (1, 4), (2, 4), (3, 4)])
>>> G.nodes[0]['community'] = 0
>>> G.nodes[1]['community'] = 1
>>> G.nodes[2]['community'] = 0
>>> G.nodes[3]['community'] = 0
>>> G.nodes[4]['community'] = 0
>>> preds = nx.within_inter_cluster(G, [(0, 4)])
>>> for u, v, p in preds:
...     '(%d, %d) -> %.8f' % (u, v, p)
...
'(0, 4) -> 1.99800200'
>>> preds = nx.within_inter_cluster(G, [(0, 4)], delta=0.5)
>>> for u, v, p in preds:
...     '(%d, %d) -> %.8f' % (u, v, p)
...
'(0, 4) -> 1.33333333'

References

[1](1, 2) Jorge Carlos Valverde-Rebaza and Alneu de Andrade Lopes. Link prediction in complex networks based on cluster information. In Proceedings of the 21st Brazilian conference on Advances in Artificial Intelligence (SBIA’12) https://doi.org/10.1007/978-3-642-34459-6_10
Next Previous

© Copyright 2004-2019, NetworkX Developers Last updated on Aug 19, 2019.

Built with Sphinx using a theme provided by Read the Docs.