Module Expr Str ImportFrom alias Import alias ImportFrom alias Import alias identifier ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias Assign NameStore NameLoad ImportFrom alias alias Assign NameStore Call AttributeLoad Str attr ListLoad Str Assign NameStore ListLoad Str Str Str Str Str Str FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam NameParam defaults NameLoad NameLoad NameLoad NameLoad body Expr Str If CompareIs NameLoad NameLoad body Assign NameStore NameLoad If CompareIs NameLoad NameLoad body Assign NameStore Call NameLoad NameLoad orelse Assign NameStore NameLoad Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Str NameLoad If CompareIs NameLoad NameLoad body Raise Call AttributeLoad NameLoad attr Str Assign NameStore Call NameLoad keyword NameLoad keyword NameLoad If CompareIs NameLoad NameLoad body Assign SubscriptStore NameLoad Index Str NameLoad Assign SubscriptStore NameLoad Index Str NameLoad orelse If CompareIs NameLoad NameLoad body Assign SubscriptStore NameLoad Index Str NameLoad orelse If CompareIs NameLoad NameLoad body Assign SubscriptStore NameLoad Index Str NameLoad Return Call AttributeLoad NameLoad attr NameLoad BinOpMod Str SubscriptLoad NameLoad Index NameLoad BinOpMod Str SubscriptLoad NameLoad Index NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults NameLoad NameLoad NameLoad body Expr Str If BoolOpOr BoolOpAnd CompareIsNot NameLoad NameLoad CompareIs NameLoad NameLoad BoolOpAnd CompareIs NameLoad NameLoad CompareIsNot NameLoad NameLoad body Raise Call AttributeLoad NameLoad attr Str If BoolOpAnd CompareIsNot NameLoad NameLoad CompareIsNot NameLoad NameLoad body If CompareNotIn NameLoad NameLoad body Raise Call AttributeLoad NameLoad attr BinOpMod Str NameLoad If CompareNotIn NameLoad NameLoad body Raise Call AttributeLoad NameLoad attr BinOpMod Str NameLoad Return Call NameLoad NameLoad NameLoad NameLoad keyword NameLoad If Call AttributeLoad NameLoad attr body If UnaryOpNot Call AttributeLoad NameLoad attr NameLoad body Return Num Assign NameStore AttributeLoad NameLoad attr FunctionDef arguments args NameParam defaults body Return Call AttributeLoad AttributeLoad NameLoad attr attr ListLoad Call AttributeLoad NameLoad attr NameLoad Call AttributeLoad NameLoad attr NameLoad decorator_list orelse If UnaryOpNot Call AttributeLoad NameLoad attr NameLoad body Return Num Assign NameStore AttributeLoad NameLoad attr Assign NameStore AttributeLoad NameLoad attr Assign NameStore Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad Str Assign NameStore Call NameLoad keyword NameLoad keyword NameLoad keyword NameLoad Assign TupleStore NameStore NameStore Call NameLoad Call AttributeLoad NameLoad attr keyword Call NameLoad Num For NameStore BinOpSub BinOpSub Call NameLoad NameLoad Call NameLoad Call NameLoad NameLoad Call NameLoad ListLoad NameLoad body Assign SubscriptStore NameLoad Index Str NameLoad Assign NameStore Call NameLoad NameLoad Call NameLoad NameLoad NameLoad NameLoad NameLoad For TupleStore NameStore NameStore Call NameLoad Call NameLoad NameLoad Num body If CompareIn NameLoad SubscriptLoad NameLoad Index NameLoad body Continue Assign SubscriptStore NameLoad Index Str NameLoad Assign NameStore Call NameLoad NameLoad Call NameLoad NameLoad NameLoad NameLoad NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults NameLoad body Expr Str If Call AttributeLoad NameLoad attr body Assign NameStore AttributeLoad NameLoad attr orelse Assign NameStore AttributeLoad NameLoad attr Assign NameStore Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad Str Assign NameStore Call NameLoad keyword NameLoad keyword NameLoad keyword NameLoad Assign TupleStore NameStore NameStore TupleLoad Num Num For TupleStore NameStore NameStore Call NameLoad NameLoad Num body AugAssignAdd NameStore Call NameLoad NameLoad NameLoad NameLoad NameLoad AugAssignAdd NameStore Num If CompareEq NameLoad Num body Return Num Return BinOpDiv NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad NameLoad body Expr Str If CompareIs NameLoad NameLoad body Assign NameStore NameLoad orelse Assign NameStore Call NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr If NameLoad body Assign NameStore AttributeLoad NameLoad attr orelse Assign NameStore AttributeLoad NameLoad attr Assign NameStore DictComp NameLoad Dict comprehension NameStore NameLoad Assign NameStore Call NameLoad NameLoad Assign NameStore SubscriptLoad AttributeLoad NameLoad attr Index Str Assign NameStore Call NameLoad NameLoad Str Assign NameStore Call NameLoad keyword NameLoad keyword NameLoad keyword NameLoad For TupleStore NameStore NameStore Call NameLoad NameLoad Num body Assign NameStore Call NameLoad NameLoad NameLoad NameLoad NameLoad Assign SubscriptStore SubscriptLoad NameLoad Index NameLoad Index NameLoad NameLoad If UnaryOpNot NameLoad body Assign SubscriptStore SubscriptLoad NameLoad Index NameLoad Index NameLoad NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam NameParam defaults NameLoad NameLoad NameLoad NameLoad body Expr Str If CompareIs NameLoad NameLoad body Assign NameStore NameLoad If CompareIs NameLoad NameLoad body Assign NameStore Call NameLoad NameLoad orelse Assign NameStore NameLoad Assign NameStore Call NameLoad keyword NameLoad keyword NameLoad If CompareIs NameLoad NameLoad body Assign SubscriptStore NameLoad Index Str NameLoad Assign SubscriptStore NameLoad Index Str NameLoad orelse If CompareIs NameLoad NameLoad body Assign SubscriptStore NameLoad Index Str NameLoad orelse If CompareIs NameLoad NameLoad body Assign SubscriptStore NameLoad Index Str NameLoad Return Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults NameLoad NameLoad NameLoad body Expr Str If BoolOpOr BoolOpAnd CompareIsNot NameLoad NameLoad CompareIs NameLoad NameLoad BoolOpAnd CompareIs NameLoad NameLoad CompareIsNot NameLoad NameLoad body Raise Call AttributeLoad NameLoad attr Str If BoolOpAnd CompareIsNot NameLoad NameLoad CompareIsNot NameLoad NameLoad body If CompareNotIn NameLoad NameLoad body Raise Call AttributeLoad NameLoad attr BinOpMod Str NameLoad If CompareNotIn NameLoad NameLoad body Raise Call AttributeLoad NameLoad attr BinOpMod Str NameLoad Return Call NameLoad NameLoad NameLoad NameLoad keyword NameLoad Assign NameStore Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad Str Assign NameStore Call NameLoad keyword NameLoad keyword NameLoad keyword NameLoad If Call AttributeLoad NameLoad attr body If UnaryOpNot Call AttributeLoad NameLoad attr NameLoad body Return Num Assign NameStore Call NameLoad GeneratorExp NameLoad comprehension TupleStore NameStore NameStore Call AttributeLoad NameLoad attr Assign NameStore Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad For NameStore Call NameLoad NameLoad body Assign SubscriptStore NameLoad Index Str NameLoad TryExcept body Assign NameStore Call NameLoad NameLoad Call NameLoad NameLoad SubscriptLoad NameLoad Index NameLoad SubscriptLoad NameLoad Index BinOpAdd NameLoad Num NameLoad handlers ExceptHandler type NameLoad body Assign NameStore Call NameLoad NameLoad Call NameLoad NameLoad SubscriptLoad NameLoad Index NameLoad SubscriptLoad NameLoad Index Num NameLoad Return NameLoad orelse If UnaryOpNot Call AttributeLoad NameLoad attr NameLoad body Return Num Assign NameStore Call NameLoad GeneratorExp NameLoad comprehension TupleStore NameStore NameStore Call AttributeLoad NameLoad attr For NameStore NameLoad body Assign NameStore Call AttributeLoad NameLoad attr NameLoad keyword NameLoad Assign NameStore Call AttributeLoad NameLoad attr If NameLoad body Break orelse Return NameLoad For NameStore NameLoad body Assign SubscriptStore NameLoad Index Str NameLoad Assign NameStore Call NameLoad NameLoad Call NameLoad NameLoad NameLoad NameLoad NameLoad Return NameLoad decorator_list
N/A N/A 
Flow based connectivity algorithms
 __future__ division N/A itertools operator itemgetter N/A networkx nx networkx.algorithms.flow dinitz networkx.algorithms.flow edmonds_karp networkx.algorithms.flow shortest_augmenting_path networkx.algorithms.flow build_residual_network N/A default_flow_func edmonds_karp utils build_auxiliary_node_connectivity build_auxiliary_edge_connectivity N/A __author__ N/A N/A join N/A Jordi Torrents <jtorrents@milnou.net> N/A __all__ N/A average_node_connectivity local_node_connectivity node_connectivity local_edge_connectivity edge_connectivity all_pairs_node_connectivity local_node_connectivity N/A N/A G s t flow_func auxiliary residual cutoff N/A None None None None N/A N/A Computes local node connectivity for nodes s and t.

    Local node connectivity for two non adjacent nodes s and t is the
    minimum number of nodes that must be removed (along with their incident
    edges) to disconnect them.

    This is a flow based implementation of node connectivity. We compute the
    maximum flow on an auxiliary digraph build from the original input
    graph (see below for details).

    Parameters
    ----------
    G : NetworkX graph
        Undirected graph

    s : node
        Source node

    t : node
        Target node

    flow_func : function
        A function for computing the maximum flow among a pair of nodes.
        The function has to accept at least three parameters: a Digraph,
        a source node, and a target node. And return a residual network
        that follows NetworkX conventions (see :meth:`maximum_flow` for
        details). If flow_func is None, the default maximum flow function
        (:meth:`edmonds_karp`) is used. See below for details. The choice
        of the default function may change from version to version and
        should not be relied on. Default value: None.

    auxiliary : NetworkX DiGraph
        Auxiliary digraph to compute flow based node connectivity. It has
        to have a graph attribute called mapping with a dictionary mapping
        node names in G and in the auxiliary digraph. If provided
        it will be reused instead of recreated. Default value: None.

    residual : NetworkX DiGraph
        Residual network to compute maximum flow. If provided it will be
        reused instead of recreated. Default value: None.

    cutoff : integer, float
        If specified, the maximum flow algorithm will terminate when the
        flow value reaches or exceeds the cutoff. This is only for the
        algorithms that support the cutoff parameter: :meth:`edmonds_karp`
        and :meth:`shortest_augmenting_path`. Other algorithms will ignore
        this parameter. Default value: None.

    Returns
    -------
    K : integer
        local node connectivity for nodes s and t

    Examples
    --------
    This function is not imported in the base NetworkX namespace, so you
    have to explicitly import it from the connectivity package:

    >>> from networkx.algorithms.connectivity import local_node_connectivity

    We use in this example the platonic icosahedral graph, which has node
    connectivity 5.

    >>> G = nx.icosahedral_graph()
    >>> local_node_connectivity(G, 0, 6)
    5

    If you need to compute local connectivity on several pairs of
    nodes in the same graph, it is recommended that you reuse the
    data structures that NetworkX uses in the computation: the
    auxiliary digraph for node connectivity, and the residual
    network for the underlying maximum flow computation.

    Example of how to compute local node connectivity among
    all pairs of nodes of the platonic icosahedral graph reusing
    the data structures.

    >>> import itertools
    >>> # You also have to explicitly import the function for
    >>> # building the auxiliary digraph from the connectivity package
    >>> from networkx.algorithms.connectivity import (
    ...     build_auxiliary_node_connectivity)
    ...
    >>> H = build_auxiliary_node_connectivity(G)
    >>> # And the function for building the residual network from the
    >>> # flow package
    >>> from networkx.algorithms.flow import build_residual_network
    >>> # Note that the auxiliary digraph has an edge attribute named capacity
    >>> R = build_residual_network(H, 'capacity')
    >>> result = dict.fromkeys(G, dict())
    >>> # Reuse the auxiliary digraph and the residual network by passing them
    >>> # as parameters
    >>> for u, v in itertools.combinations(G, 2):
    ...     k = local_node_connectivity(G, u, v, auxiliary=H, residual=R)
    ...     result[u][v] = k
    ...
    >>> all(result[u][v] == 5 for u, v in itertools.combinations(G, 2))
    True

    You can also use alternative flow algorithms for computing node
    connectivity. For instance, in dense networks the algorithm
    :meth:`shortest_augmenting_path` will usually perform better than
    the default :meth:`edmonds_karp` which is faster for sparse
    networks with highly skewed degree distributions. Alternative flow
    functions have to be explicitly imported from the flow package.

    >>> from networkx.algorithms.flow import shortest_augmenting_path
    >>> local_node_connectivity(G, 0, 6, flow_func=shortest_augmenting_path)
    5

    Notes
    -----
    This is a flow based implementation of node connectivity. We compute the
    maximum flow using, by default, the :meth:`edmonds_karp` algorithm (see:
    :meth:`maximum_flow`) on an auxiliary digraph build from the original
    input graph:

    For an undirected graph G having `n` nodes and `m` edges we derive a
    directed graph H with `2n` nodes and `2m+n` arcs by replacing each
    original node `v` with two nodes `v_A`, `v_B` linked by an (internal)
    arc in H. Then for each edge (`u`, `v`) in G we add two arcs
    (`u_B`, `v_A`) and (`v_B`, `u_A`) in H. Finally we set the attribute
    capacity = 1 for each arc in H [1]_ .

    For a directed graph G having `n` nodes and `m` arcs we derive a
    directed graph H with `2n` nodes and `m+n` arcs by replacing each
    original node `v` with two nodes `v_A`, `v_B` linked by an (internal)
    arc (`v_A`, `v_B`) in H. Then for each arc (`u`, `v`) in G we add one arc
    (`u_B`, `v_A`) in H. Finally we set the attribute capacity = 1 for
    each arc in H.

    This is equal to the local node connectivity because the value of
    a maximum s-t-flow is equal to the capacity of a minimum s-t-cut.

    See also
    --------
    :meth:`local_edge_connectivity`
    :meth:`node_connectivity`
    :meth:`minimum_node_cut`
    :meth:`maximum_flow`
    :meth:`edmonds_karp`
    :meth:`preflow_push`
    :meth:`shortest_augmenting_path`

    References
    ----------
    .. [1] Kammer, Frank and Hanjo Taubig. Graph Connectivity. in Brandes and
        Erlebach, 'Network Analysis: Methodological Foundations', Lecture
        Notes in Computer Science, Volume 3418, Springer-Verlag, 2005.
        http://www.informatik.uni-augsburg.de/thi/personen/kammer/Graph_Connectivity.pdf

     N/A N/A flow_func None N/A N/A flow_func default_flow_func N/A N/A auxiliary None N/A N/A H N/A build_auxiliary_node_connectivity G N/A N/A H auxiliary N/A mapping N/A N/A N/A H graph get mapping None N/A N/A mapping None N/A N/A N/A N/A nx NetworkXError Invalid auxiliary digraph. N/A kwargs N/A dict flow_func flow_func residual residual N/A N/A flow_func shortest_augmenting_path N/A N/A N/A kwargs N/A cutoff cutoff N/A N/A kwargs N/A two_phase True N/A N/A N/A flow_func edmonds_karp N/A N/A N/A kwargs N/A cutoff cutoff N/A N/A N/A flow_func dinitz N/A N/A N/A kwargs N/A cutoff cutoff N/A N/A N/A nx maximum_flow_value H N/A %sB N/A mapping N/A s N/A %sA N/A mapping N/A t kwargs N/A node_connectivity N/A N/A G s t flow_func N/A None None None N/A N/A Returns node connectivity for a graph or digraph G.

    Node connectivity is equal to the minimum number of nodes that
    must be removed to disconnect G or render it trivial. If source
    and target nodes are provided, this function returns the local node
    connectivity: the minimum number of nodes that must be removed to break
    all paths from source to target in G.

    Parameters
    ----------
    G : NetworkX graph
        Undirected graph

    s : node
        Source node. Optional. Default value: None.

    t : node
        Target node. Optional. Default value: None.

    flow_func : function
        A function for computing the maximum flow among a pair of nodes.
        The function has to accept at least three parameters: a Digraph,
        a source node, and a target node. And return a residual network
        that follows NetworkX conventions (see :meth:`maximum_flow` for
        details). If flow_func is None, the default maximum flow function
        (:meth:`edmonds_karp`) is used. See below for details. The
        choice of the default function may change from version
        to version and should not be relied on. Default value: None.

    Returns
    -------
    K : integer
        Node connectivity of G, or local node connectivity if source
        and target are provided.

    Examples
    --------
    >>> # Platonic icosahedral graph is 5-node-connected
    >>> G = nx.icosahedral_graph()
    >>> nx.node_connectivity(G)
    5

    You can use alternative flow algorithms for the underlying maximum
    flow computation. In dense networks the algorithm
    :meth:`shortest_augmenting_path` will usually perform better
    than the default :meth:`edmonds_karp`, which is faster for
    sparse networks with highly skewed degree distributions. Alternative
    flow functions have to be explicitly imported from the flow package.

    >>> from networkx.algorithms.flow import shortest_augmenting_path
    >>> nx.node_connectivity(G, flow_func=shortest_augmenting_path)
    5

    If you specify a pair of nodes (source and target) as parameters,
    this function returns the value of local node connectivity.

    >>> nx.node_connectivity(G, 3, 7)
    5

    If you need to perform several local computations among different
    pairs of nodes on the same graph, it is recommended that you reuse
    the data structures used in the maximum flow computations. See
    :meth:`local_node_connectivity` for details.

    Notes
    -----
    This is a flow based implementation of node connectivity. The
    algorithm works by solving `O((n-\delta-1+\delta(\delta-1)/2))`
    maximum flow problems on an auxiliary digraph. Where `\delta`
    is the minimum degree of G. For details about the auxiliary
    digraph and the computation of local node connectivity see
    :meth:`local_node_connectivity`. This implementation is based
    on algorithm 11 in [1]_.

    See also
    --------
    :meth:`local_node_connectivity`
    :meth:`edge_connectivity`
    :meth:`maximum_flow`
    :meth:`edmonds_karp`
    :meth:`preflow_push`
    :meth:`shortest_augmenting_path`

    References
    ----------
    .. [1] Abdol-Hossein Esfahanian. Connectivity Algorithms.
        http://www.cse.msu.edu/~cse835/Papers/Graph_connectivity_revised.pdf

     N/A N/A N/A N/A s None N/A t None N/A N/A s None N/A t None N/A N/A N/A N/A nx NetworkXError Both source and target must be specified. N/A N/A N/A s None N/A t None N/A N/A N/A s G N/A N/A N/A N/A nx NetworkXError N/A node %s not in graph s N/A N/A t G N/A N/A N/A N/A nx NetworkXError N/A node %s not in graph t N/A N/A local_node_connectivity G s t flow_func flow_func N/A N/A N/A G is_directed N/A N/A N/A N/A N/A nx is_weakly_connected G N/A N/A 0 N/A iter_func N/A itertools permutations neighbors N/A N/A v N/A N/A N/A N/A N/A N/A itertools chain from_iterable N/A N/A N/A G predecessors v N/A N/A G successors v N/A N/A N/A N/A N/A N/A nx is_connected G N/A N/A 0 N/A iter_func N/A itertools combinations N/A neighbors N/A G neighbors N/A H N/A build_auxiliary_node_connectivity G N/A R N/A build_residual_network H capacity N/A kwargs N/A dict flow_func flow_func auxiliary H residual R N/A N/A v K N/A min N/A N/A G degree key N/A itemgetter 1 N/A w N/A N/A N/A set G N/A set N/A neighbors v N/A set N/A v N/A N/A N/A kwargs N/A cutoff K N/A K N/A min K N/A local_node_connectivity G v w kwargs N/A N/A x y N/A iter_func N/A neighbors v 2 N/A N/A N/A y N/A G N/A x N/A N/A N/A N/A kwargs N/A cutoff K N/A K N/A min K N/A local_node_connectivity G x y kwargs N/A K N/A average_node_connectivity N/A N/A G flow_func N/A None N/A N/A Returns the average connectivity of a graph G.

    The average connectivity `\bar{\kappa}` of a graph G is the average
    of local node connectivity over all pairs of nodes of G [1]_ .

    .. math::

        \bar{\kappa}(G) = \frac{\sum_{u,v} \kappa_{G}(u,v)}{{n \choose 2}}

    Parameters
    ----------

    G : NetworkX graph
        Undirected graph

    flow_func : function
        A function for computing the maximum flow among a pair of nodes.
        The function has to accept at least three parameters: a Digraph,
        a source node, and a target node. And return a residual network
        that follows NetworkX conventions (see :meth:`maximum_flow` for
        details). If flow_func is None, the default maximum flow function
        (:meth:`edmonds_karp`) is used. See :meth:`local_node_connectivity`
        for details. The choice of the default function may change from
        version to version and should not be relied on. Default value: None.

    Returns
    -------
    K : float
        Average node connectivity

    See also
    --------
    :meth:`local_node_connectivity`
    :meth:`node_connectivity`
    :meth:`edge_connectivity`
    :meth:`maximum_flow`
    :meth:`edmonds_karp`
    :meth:`preflow_push`
    :meth:`shortest_augmenting_path`

    References
    ----------
    .. [1]  Beineke, L., O. Oellermann, and R. Pippert (2002). The average
            connectivity of a graph. Discrete mathematics 252(1-3), 31-45.
            http://www.sciencedirect.com/science/article/pii/S0012365X01001807

     N/A N/A N/A G is_directed N/A N/A iter_func N/A itertools permutations N/A N/A iter_func N/A itertools combinations N/A H N/A build_auxiliary_node_connectivity G N/A R N/A build_residual_network H capacity N/A kwargs N/A dict flow_func flow_func auxiliary H residual R N/A N/A num den N/A 0 0 N/A N/A u v N/A iter_func G 2 N/A N/A num N/A local_node_connectivity G u v kwargs N/A den 1 N/A N/A den 0 N/A N/A 0 N/A N/A num den N/A all_pairs_node_connectivity N/A N/A G nbunch flow_func N/A None None N/A N/A Compute node connectivity between all pairs of nodes of G.

    Parameters
    ----------
    G : NetworkX graph
        Undirected graph

    nbunch: container
        Container of nodes. If provided node connectivity will be computed
        only over pairs of nodes in nbunch.

    flow_func : function
        A function for computing the maximum flow among a pair of nodes.
        The function has to accept at least three parameters: a Digraph,
        a source node, and a target node. And return a residual network
        that follows NetworkX conventions (see :meth:`maximum_flow` for
        details). If flow_func is None, the default maximum flow function
        (:meth:`edmonds_karp`) is used. See below for details. The
        choice of the default function may change from version
        to version and should not be relied on. Default value: None.

    Returns
    -------
    all_pairs : dict
        A dictionary with node connectivity between all pairs of nodes
        in G, or in nbunch if provided.

    See also
    --------
    :meth:`local_node_connectivity`
    :meth:`edge_connectivity`
    :meth:`local_edge_connectivity`
    :meth:`maximum_flow`
    :meth:`edmonds_karp`
    :meth:`preflow_push`
    :meth:`shortest_augmenting_path`

     N/A N/A nbunch None N/A N/A nbunch G N/A N/A nbunch N/A set nbunch N/A directed N/A N/A G is_directed N/A directed N/A N/A iter_func N/A itertools permutations N/A N/A iter_func N/A itertools combinations N/A all_pairs N/A n N/A N/A n nbunch N/A H N/A build_auxiliary_node_connectivity G N/A mapping N/A N/A H graph N/A mapping N/A R N/A build_residual_network H capacity N/A kwargs N/A dict flow_func flow_func auxiliary H residual R N/A N/A u v N/A iter_func nbunch 2 N/A N/A K N/A local_node_connectivity G u v kwargs N/A N/A N/A all_pairs N/A u N/A v K N/A N/A directed N/A N/A N/A N/A all_pairs N/A v N/A u K N/A all_pairs N/A local_edge_connectivity N/A N/A G u v flow_func auxiliary residual cutoff N/A None None None None N/A N/A Returns local edge connectivity for nodes s and t in G.

    Local edge connectivity for two nodes s and t is the minimum number
    of edges that must be removed to disconnect them.

    This is a flow based implementation of edge connectivity. We compute the
    maximum flow on an auxiliary digraph build from the original
    network (see below for details). This is equal to the local edge
    connectivity because the value of a maximum s-t-flow is equal to the
    capacity of a minimum s-t-cut (Ford and Fulkerson theorem) [1]_ .

    Parameters
    ----------
    G : NetworkX graph
        Undirected or directed graph

    s : node
        Source node

    t : node
        Target node

    flow_func : function
        A function for computing the maximum flow among a pair of nodes.
        The function has to accept at least three parameters: a Digraph,
        a source node, and a target node. And return a residual network
        that follows NetworkX conventions (see :meth:`maximum_flow` for
        details). If flow_func is None, the default maximum flow function
        (:meth:`edmonds_karp`) is used. See below for details. The
        choice of the default function may change from version
        to version and should not be relied on. Default value: None.

    auxiliary : NetworkX DiGraph
        Auxiliary digraph for computing flow based edge connectivity. If
        provided it will be reused instead of recreated. Default value: None.

    residual : NetworkX DiGraph
        Residual network to compute maximum flow. If provided it will be
        reused instead of recreated. Default value: None.

    cutoff : integer, float
        If specified, the maximum flow algorithm will terminate when the
        flow value reaches or exceeds the cutoff. This is only for the
        algorithms that support the cutoff parameter: :meth:`edmonds_karp`
        and :meth:`shortest_augmenting_path`. Other algorithms will ignore
        this parameter. Default value: None.

    Returns
    -------
    K : integer
        local edge connectivity for nodes s and t.

    Examples
    --------
    This function is not imported in the base NetworkX namespace, so you
    have to explicitly import it from the connectivity package:

    >>> from networkx.algorithms.connectivity import local_edge_connectivity

    We use in this example the platonic icosahedral graph, which has edge
    connectivity 5.

    >>> G = nx.icosahedral_graph()
    >>> local_edge_connectivity(G, 0, 6)
    5

    If you need to compute local connectivity on several pairs of
    nodes in the same graph, it is recommended that you reuse the
    data structures that NetworkX uses in the computation: the
    auxiliary digraph for edge connectivity, and the residual
    network for the underlying maximum flow computation.

    Example of how to compute local edge connectivity among
    all pairs of nodes of the platonic icosahedral graph reusing
    the data structures.

    >>> import itertools
    >>> # You also have to explicitly import the function for
    >>> # building the auxiliary digraph from the connectivity package
    >>> from networkx.algorithms.connectivity import (
    ...     build_auxiliary_edge_connectivity)
    >>> H = build_auxiliary_edge_connectivity(G)
    >>> # And the function for building the residual network from the
    >>> # flow package
    >>> from networkx.algorithms.flow import build_residual_network
    >>> # Note that the auxiliary digraph has an edge attribute named capacity
    >>> R = build_residual_network(H, 'capacity')
    >>> result = dict.fromkeys(G, dict())
    >>> # Reuse the auxiliary digraph and the residual network by passing them
    >>> # as parameters
    >>> for u, v in itertools.combinations(G, 2):
    ...     k = local_edge_connectivity(G, u, v, auxiliary=H, residual=R)
    ...     result[u][v] = k
    >>> all(result[u][v] == 5 for u, v in itertools.combinations(G, 2))
    True

    You can also use alternative flow algorithms for computing edge
    connectivity. For instance, in dense networks the algorithm
    :meth:`shortest_augmenting_path` will usually perform better than
    the default :meth:`edmonds_karp` which is faster for sparse
    networks with highly skewed degree distributions. Alternative flow
    functions have to be explicitly imported from the flow package.

    >>> from networkx.algorithms.flow import shortest_augmenting_path
    >>> local_edge_connectivity(G, 0, 6, flow_func=shortest_augmenting_path)
    5

    Notes
    -----
    This is a flow based implementation of edge connectivity. We compute the
    maximum flow using, by default, the :meth:`edmonds_karp` algorithm on an
    auxiliary digraph build from the original input graph:

    If the input graph is undirected, we replace each edge (`u`,`v`) with
    two reciprocal arcs (`u`, `v`) and (`v`, `u`) and then we set the attribute
    'capacity' for each arc to 1. If the input graph is directed we simply
    add the 'capacity' attribute. This is an implementation of algorithm 1
    in [1]_.

    The maximum flow in the auxiliary network is equal to the local edge
    connectivity because the value of a maximum s-t-flow is equal to the
    capacity of a minimum s-t-cut (Ford and Fulkerson theorem).

    See also
    --------
    :meth:`edge_connectivity`
    :meth:`local_node_connectivity`
    :meth:`node_connectivity`
    :meth:`maximum_flow`
    :meth:`edmonds_karp`
    :meth:`preflow_push`
    :meth:`shortest_augmenting_path`

    References
    ----------
    .. [1] Abdol-Hossein Esfahanian. Connectivity Algorithms.
        http://www.cse.msu.edu/~cse835/Papers/Graph_connectivity_revised.pdf

     N/A N/A flow_func None N/A N/A flow_func default_flow_func N/A N/A auxiliary None N/A N/A H N/A build_auxiliary_edge_connectivity G N/A N/A H auxiliary N/A kwargs N/A dict flow_func flow_func residual residual N/A N/A flow_func shortest_augmenting_path N/A N/A N/A kwargs N/A cutoff cutoff N/A N/A kwargs N/A two_phase True N/A N/A N/A flow_func edmonds_karp N/A N/A N/A kwargs N/A cutoff cutoff N/A N/A N/A flow_func dinitz N/A N/A N/A kwargs N/A cutoff cutoff N/A N/A N/A nx maximum_flow_value H u v kwargs N/A edge_connectivity N/A N/A G s t flow_func N/A None None None N/A N/A Returns the edge connectivity of the graph or digraph G.

    The edge connectivity is equal to the minimum number of edges that
    must be removed to disconnect G or render it trivial. If source
    and target nodes are provided, this function returns the local edge
    connectivity: the minimum number of edges that must be removed to
    break all paths from source to target in G.

    Parameters
    ----------
    G : NetworkX graph
        Undirected or directed graph

    s : node
        Source node. Optional. Default value: None.

    t : node
        Target node. Optional. Default value: None.

    flow_func : function
        A function for computing the maximum flow among a pair of nodes.
        The function has to accept at least three parameters: a Digraph,
        a source node, and a target node. And return a residual network
        that follows NetworkX conventions (see :meth:`maximum_flow` for
        details). If flow_func is None, the default maximum flow function
        (:meth:`edmonds_karp`) is used. See below for details. The
        choice of the default function may change from version
        to version and should not be relied on. Default value: None.

    Returns
    -------
    K : integer
        Edge connectivity for G, or local edge connectivity if source
        and target were provided

    Examples
    --------
    >>> # Platonic icosahedral graph is 5-edge-connected
    >>> G = nx.icosahedral_graph()
    >>> nx.edge_connectivity(G)
    5

    You can use alternative flow algorithms for the underlying
    maximum flow computation. In dense networks the algorithm
    :meth:`shortest_augmenting_path` will usually perform better
    than the default :meth:`edmonds_karp`, which is faster for
    sparse networks with highly skewed degree distributions.
    Alternative flow functions have to be explicitly imported
    from the flow package.

    >>> from networkx.algorithms.flow import shortest_augmenting_path
    >>> nx.edge_connectivity(G, flow_func=shortest_augmenting_path)
    5

    If you specify a pair of nodes (source and target) as parameters,
    this function returns the value of local edge connectivity.

    >>> nx.edge_connectivity(G, 3, 7)
    5

    If you need to perform several local computations among different
    pairs of nodes on the same graph, it is recommended that you reuse
    the data structures used in the maximum flow computations. See
    :meth:`local_edge_connectivity` for details.

    Notes
    -----
    This is a flow based implementation of global edge connectivity.
    For undirected graphs the algorithm works by finding a 'small'
    dominating set of nodes of G (see algorithm 7 in [1]_ ) and
    computing local maximum flow (see :meth:`local_edge_connectivity`)
    between an arbitrary node in the dominating set and the rest of
    nodes in it. This is an implementation of algorithm 6 in [1]_ .
    For directed graphs, the algorithm does n calls to the maximum
    flow function. This is an implementation of algorithm 8 in [1]_ .

    See also
    --------
    :meth:`local_edge_connectivity`
    :meth:`local_node_connectivity`
    :meth:`node_connectivity`
    :meth:`maximum_flow`
    :meth:`edmonds_karp`
    :meth:`preflow_push`
    :meth:`shortest_augmenting_path`

    References
    ----------
    .. [1] Abdol-Hossein Esfahanian. Connectivity Algorithms.
        http://www.cse.msu.edu/~cse835/Papers/Graph_connectivity_revised.pdf

     N/A N/A N/A N/A s None N/A t None N/A N/A s None N/A t None N/A N/A N/A N/A nx NetworkXError Both source and target must be specified. N/A N/A N/A s None N/A t None N/A N/A N/A s G N/A N/A N/A N/A nx NetworkXError N/A node %s not in graph s N/A N/A t G N/A N/A N/A N/A nx NetworkXError N/A node %s not in graph t N/A N/A local_edge_connectivity G s t flow_func flow_func N/A H N/A build_auxiliary_edge_connectivity G N/A R N/A build_residual_network H capacity N/A kwargs N/A dict flow_func flow_func auxiliary H residual R N/A N/A N/A G is_directed N/A N/A N/A N/A N/A nx is_weakly_connected G N/A N/A 0 N/A L N/A min N/A d N/A N/A n d N/A N/A G degree N/A nodes N/A list G N/A n N/A len nodes N/A i N/A range n N/A N/A N/A kwargs N/A cutoff L N/A N/A N/A L N/A min L N/A local_edge_connectivity G N/A nodes N/A i N/A nodes N/A N/A i 1 kwargs N/A N/A N/A IndexError N/A N/A L N/A min L N/A local_edge_connectivity G N/A nodes N/A i N/A nodes N/A 0 kwargs N/A L N/A N/A N/A N/A N/A nx is_connected G N/A N/A 0 N/A L N/A min N/A d N/A N/A n d N/A N/A G degree N/A node G N/A N/A D N/A N/A nx dominating_set G start_with node N/A v N/A N/A D pop N/A D N/A N/A N/A N/A L N/A w D N/A N/A N/A kwargs N/A cutoff L N/A L N/A min L N/A local_edge_connectivity G v w kwargs N/A L N/A