def edge_current_flow_betweenness_centrality_subset(G, sources, targets, normalized=True, weight='weight', dtype=float, solver='lu'):
    'Compute current-flow betweenness centrality for edges using subsets \n    of nodes.\n\n    Current-flow betweenness centrality uses an electrical current\n    model for information spreading in contrast to betweenness\n    centrality which uses shortest paths.\n\n    Current-flow betweenness centrality is also known as\n    random-walk betweenness centrality [2]_.\n\n    Parameters\n    ----------\n    G : graph\n      A NetworkX graph \n\n    sources: list of nodes\n      Nodes to use as sources for current\n\n    targets: list of nodes\n      Nodes to use as sinks for current\n\n    normalized : bool, optional (default=True)\n      If True the betweenness values are normalized by b=b/(n-1)(n-2) where\n      n is the number of nodes in G.\n\n    weight : string or None, optional (default=\'weight\')\n      Key for edge data used as the edge weight.\n      If None, then use 1 as each edge weight.\n\n    dtype: data type (float)\n      Default data type for internal matrices.\n      Set to np.float32 for lower memory consumption.\n\n    solver: string (default=\'lu\')\n       Type of linear solver to use for computing the flow matrix.\n       Options are "full" (uses most memory), "lu" (recommended), and \n       "cg" (uses least memory).\n\n    Returns\n    -------\n    nodes : dictionary\n       Dictionary of edge tuples with betweenness centrality as the value.\n        \n    See Also\n    --------\n    betweenness_centrality\n    edge_betweenness_centrality\n    current_flow_betweenness_centrality\n\n    Notes\n    -----\n    Current-flow betweenness can be computed in `O(I(n-1)+mn \\log n)`\n    time [1]_, where `I(n-1)` is the time needed to compute the \n    inverse Laplacian.  For a full matrix this is `O(n^3)` but using\n    sparse methods you can achieve `O(nm{\\sqrt k})` where `k` is the\n    Laplacian matrix condition number.  \n\n    The space required is `O(nw) where `w` is the width of the sparse\n    Laplacian matrix.  Worse case is `w=n` for `O(n^2)`.\n\n    If the edges have a \'weight\' attribute they will be used as \n    weights in this algorithm.  Unspecified weights are set to 1.\n\n    References\n    ----------\n    .. [1] Centrality Measures Based on Current Flow. \n       Ulrik Brandes and Daniel Fleischer,\n       Proc. 22nd Symp. Theoretical Aspects of Computer Science (STACS \'05). \n       LNCS 3404, pp. 533-544. Springer-Verlag, 2005. \n       http://www.inf.uni-konstanz.de/algo/publications/bf-cmbcf-05.pdf\n\n    .. [2] A measure of betweenness centrality based on random walks, \n       M. E. J. Newman, Social Networks 27, 39-54 (2005).\n    '
    from networkx.utils import reverse_cuthill_mckee_ordering
    try:
        import numpy as np
    except ImportError:
        raise ImportError('current_flow_betweenness_centrality requires NumPy ', 'http://scipy.org/')
    try:
        import scipy
    except ImportError:
        raise ImportError('current_flow_betweenness_centrality requires SciPy ', 'http://scipy.org/')
    if G.is_directed():
        raise nx.NetworkXError('edge_current_flow_betweenness_centrality ', 'not defined for digraphs.')
    if (not nx.is_connected(G)):
        raise nx.NetworkXError('Graph not connected.')
    n = G.number_of_nodes()
    ordering = list(reverse_cuthill_mckee_ordering(G))
    mapping = dict(zip(ordering, range(n)))
    H = nx.relabel_nodes(G, mapping)
    betweenness = dict.fromkeys(H.edges(), 0.0)
    if normalized:
        nb = ((n - 1.0) * (n - 2.0))
    else:
        nb = 2.0
    for (row, e) in flow_matrix_row(H, weight=weight, dtype=dtype, solver=solver):
        for ss in sources:
            i = mapping[ss]
            for tt in targets:
                j = mapping[tt]
                betweenness[e] += (0.5 * np.abs((row[i] - row[j])))
        betweenness[e] /= nb
    return dict((((ordering[s], ordering[t]), v) for ((s, t), v) in betweenness.items()))
Compute current-flow betweenness centrality for edges using subsets 
of nodes.

Current-flow betweenness centrality uses an electrical current
model for information spreading in contrast to betweenness
centrality which uses shortest paths.

Current-flow betweenness centrality is also known as
random-walk betweenness centrality [2]_.

Parameters
----------
G : graph
  A NetworkX graph 

sources: list of nodes
  Nodes to use as sources for current

targets: list of nodes
  Nodes to use as sinks for current

normalized : bool, optional (default=True)
  If True the betweenness values are normalized by b=b/(n-1)(n-2) where
  n is the number of nodes in G.

weight : string or None, optional (default='weight')
  Key for edge data used as the edge weight.
  If None, then use 1 as each edge weight.

dtype: data type (float)
  Default data type for internal matrices.
  Set to np.float32 for lower memory consumption.

solver: string (default='lu')
   Type of linear solver to use for computing the flow matrix.
   Options are "full" (uses most memory), "lu" (recommended), and 
   "cg" (uses least memory).

Returns
-------
nodes : dictionary
   Dictionary of edge tuples with betweenness centrality as the value.
    
See Also
--------
betweenness_centrality
edge_betweenness_centrality
current_flow_betweenness_centrality

Notes
-----
Current-flow betweenness can be computed in `O(I(n-1)+mn \log n)`
time [1]_, where `I(n-1)` is the time needed to compute the 
inverse Laplacian.  For a full matrix this is `O(n^3)` but using
sparse methods you can achieve `O(nm{\sqrt k})` where `k` is the
Laplacian matrix condition number.  

The space required is `O(nw) where `w` is the width of the sparse
Laplacian matrix.  Worse case is `w=n` for `O(n^2)`.

If the edges have a 'weight' attribute they will be used as 
weights in this algorithm.  Unspecified weights are set to 1.

References
----------
.. [1] Centrality Measures Based on Current Flow. 
   Ulrik Brandes and Daniel Fleischer,
   Proc. 22nd Symp. Theoretical Aspects of Computer Science (STACS '05). 
   LNCS 3404, pp. 533-544. Springer-Verlag, 2005. 
   http://www.inf.uni-konstanz.de/algo/publications/bf-cmbcf-05.pdf

.. [2] A measure of betweenness centrality based on random walks, 
   M. E. J. Newman, Social Networks 27, 39-54 (2005).
def edge_current_flow_betweenness_centrality_subset(G, sources, targets, normalized=True, weight='weight', dtype=float, solver='lu'):
    'Compute current-flow betweenness centrality for edges using subsets \n    of nodes.\n\n    Current-flow betweenness centrality uses an electrical current\n    model for information spreading in contrast to betweenness\n    centrality which uses shortest paths.\n\n    Current-flow betweenness centrality is also known as\n    random-walk betweenness centrality [2]_.\n\n    Parameters\n    ----------\n    G : graph\n      A NetworkX graph \n\n    sources: list of nodes\n      Nodes to use as sources for current\n\n    targets: list of nodes\n      Nodes to use as sinks for current\n\n    normalized : bool, optional (default=True)\n      If True the betweenness values are normalized by b=b/(n-1)(n-2) where\n      n is the number of nodes in G.\n\n    weight : string or None, optional (default=\'weight\')\n      Key for edge data used as the edge weight.\n      If None, then use 1 as each edge weight.\n\n    dtype: data type (float)\n      Default data type for internal matrices.\n      Set to np.float32 for lower memory consumption.\n\n    solver: string (default=\'lu\')\n       Type of linear solver to use for computing the flow matrix.\n       Options are "full" (uses most memory), "lu" (recommended), and \n       "cg" (uses least memory).\n\n    Returns\n    -------\n    nodes : dictionary\n       Dictionary of edge tuples with betweenness centrality as the value.\n        \n    See Also\n    --------\n    betweenness_centrality\n    edge_betweenness_centrality\n    current_flow_betweenness_centrality\n\n    Notes\n    -----\n    Current-flow betweenness can be computed in `O(I(n-1)+mn \\log n)`\n    time [1]_, where `I(n-1)` is the time needed to compute the \n    inverse Laplacian.  For a full matrix this is `O(n^3)` but using\n    sparse methods you can achieve `O(nm{\\sqrt k})` where `k` is the\n    Laplacian matrix condition number.  \n\n    The space required is `O(nw) where `w` is the width of the sparse\n    Laplacian matrix.  Worse case is `w=n` for `O(n^2)`.\n\n    If the edges have a \'weight\' attribute they will be used as \n    weights in this algorithm.  Unspecified weights are set to 1.\n\n    References\n    ----------\n    .. [1] Centrality Measures Based on Current Flow. \n       Ulrik Brandes and Daniel Fleischer,\n       Proc. 22nd Symp. Theoretical Aspects of Computer Science (STACS \'05). \n       LNCS 3404, pp. 533-544. Springer-Verlag, 2005. \n       http://www.inf.uni-konstanz.de/algo/publications/bf-cmbcf-05.pdf\n\n    .. [2] A measure of betweenness centrality based on random walks, \n       M. E. J. Newman, Social Networks 27, 39-54 (2005).\n    '
    from networkx.utils import reverse_cuthill_mckee_ordering
    try:
        import numpy as np
    except ImportError:
        raise ImportError('current_flow_betweenness_centrality requires NumPy ', 'http://scipy.org/')
    try:
        import scipy
    except ImportError:
        raise ImportError('current_flow_betweenness_centrality requires SciPy ', 'http://scipy.org/')
    if G.is_directed():
        raise nx.NetworkXError('edge_current_flow_betweenness_centrality ', 'not defined for digraphs.')
    if (not nx.is_connected(G)):
        raise nx.NetworkXError('Graph not connected.')
    n = G.number_of_nodes()
    ordering = list(reverse_cuthill_mckee_ordering(G))
    mapping = dict(zip(ordering, range(n)))
    H = nx.relabel_nodes(G, mapping)
    betweenness = dict.fromkeys(H.edges(), 0.0)
    if normalized:
        nb = ((n - 1.0) * (n - 2.0))
    else:
        nb = 2.0
    for (row, e) in flow_matrix_row(H, weight=weight, dtype=dtype, solver=solver):
        for ss in sources:
            i = mapping[ss]
            for tt in targets:
                j = mapping[tt]
                betweenness[e] += (0.5 * np.abs((row[i] - row[j])))
        betweenness[e] /= nb
    return dict((((ordering[s], ordering[t]), v) for ((s, t), v) in betweenness.items()))