ó žÃÒYc@ s¤dZddlmZddlmZddlZddlmZddl m Z dd d gZ e d ƒd „ƒZ e d ƒd „ƒZ e d ƒd„ƒZdS(sDProvides functions for computing the efficiency of nodes and graphs.iÿÿÿÿ(tdivision(t permutationsN(tNetworkXNoPathi(tnot_implemented_fort efficiencytlocal_efficiencytglobal_efficiencytdirectedcC s;ydtj|||ƒ}Wntk r6d}nX|S(s»Returns the efficiency of a pair of nodes in a graph. The *efficiency* of a pair of nodes is the multiplicative inverse of the shortest path distance between the nodes [1]_. Returns 0 if no path between nodes. Parameters ---------- G : :class:`networkx.Graph` An undirected graph for which to compute the average local efficiency. u, v : node Nodes in the graph ``G``. Returns ------- float Multiplicative inverse of the shortest path distance between the nodes. Notes ----- Edge weights are ignored when computing the shortest path distances. See also -------- local_efficiency global_efficiency References ---------- .. [1] Latora, Vito, and Massimo Marchiori. "Efficient behavior of small-world networks." *Physical Review Letters* 87.19 (2001): 198701. ii(tnxtshortest_path_lengthR(tGtutvteff((st/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/networkx/networkx/algorithms/efficiency.pyRs %  c s\tˆƒ}||d}|dkrRt‡fd†tˆdƒDƒƒ|}nd}|S(sReturns the average global efficiency of the graph. The *efficiency* of a pair of nodes in a graph is the multiplicative inverse of the shortest path distance between the nodes. The *average global efficiency* of a graph is the average efficiency of all pairs of nodes [1]_. Parameters ---------- G : :class:`networkx.Graph` An undirected graph for which to compute the average global efficiency. Returns ------- float The average global efficiency of the graph. Notes ----- Edge weights are ignored when computing the shortest path distances. See also -------- local_efficiency References ---------- .. [1] Latora, Vito, and Massimo Marchiori. "Efficient behavior of small-world networks." *Physical Review Letters* 87.19 (2001): 198701. iic3 s'|]\}}tˆ||ƒVqdS(N(R(t.0R R (R (st/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/networkx/networkx/algorithms/efficiency.pys gsi(tlentsumR(R tntdenomtg_eff((R st/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/networkx/networkx/algorithms/efficiency.pyRAs #  ,c s$t‡fd†ˆDƒƒtˆƒS(sReturns the average local efficiency of the graph. The *efficiency* of a pair of nodes in a graph is the multiplicative inverse of the shortest path distance between the nodes. The *local efficiency* of a node in the graph is the average global efficiency of the subgraph induced by the neighbors of the node. The *average local efficiency* is the average of the local efficiencies of each node [1]_. Parameters ---------- G : :class:`networkx.Graph` An undirected graph for which to compute the average local efficiency. Returns ------- float The average local efficiency of the graph. Notes ----- Edge weights are ignored when computing the shortest path distances. See also -------- global_efficiency References ---------- .. [1] Latora, Vito, and Massimo Marchiori. "Efficient behavior of small-world networks." *Physical Review Letters* 87.19 (2001): 198701. c3 s'|]}ttjˆ|ƒƒVqdS(N(RRt ego_graph(RR (R (st/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/networkx/networkx/algorithms/efficiency.pys –s(RR(R ((R st/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/networkx/networkx/algorithms/efficiency.pyRqs%(t__doc__t __future__Rt itertoolsRtnetworkxRtnetworkx.exceptionRtutilsRt__all__RRR(((st/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/networkx/networkx/algorithms/efficiency.pyt s ,0