Networkx cannot find some packages (version 1.10)

I use networkx to calculate min_maximal_matching, it gave the following error: I did pip install networkx --upgradeonversion 1.10

    >>> nx.min_maximal_matching
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    AttributeError: 'module' object has no attribute 'min_maximal_matching'
    >>> nx.__version__
    '1.10'

Just to do a health check, I tried another method from the same function group, ( approximation packages ), and it worked,

    >>> nx.node_connectivity
    <function node_connectivity at 0x10b517410>

Thanks! PS: I usepython 2.7.8

+4
source share
1 answer

The function does not appear in the namespace netxwork, but if you import networkx.algorithms.approximation, you will find it there:

In [311]: import networkx.algorithms.approximation as naa

In [312]: naa.min_maximal_matching
Out[319]: <function networkx.algorithms.approximation.matching.min_maximal_matching>

I found this by following the link you provided in the min_maximal_matching doc of the page in the source code .

, : networkx.algorithms.approximation.matching.

networkx/algorithms/approximation/__init__.py networkx.algorithms.approximation.matching networkx.algorthims.approximation:

from networkx.algorithms.approximation.matching import *

import networkx.algorithms.approximation as naa

, ,

In [307]: import networkx.algorithms.approximation.matching as naam

In [308]: naam.min_maximal_matching
Out[310]: <function networkx.algorithms.approximation.matching.min_maximal_matching>

, , .

+4

Source: https://habr.com/ru/post/1623849/


All Articles