Re: [networkx-discuss] 'module' object has no attribute 'all_shotest_paths'

1,986 views
Skip to first unread message

Dan Schult

unread,
Nov 14, 2012, 5:30:19 PM11/14/12
to networkx...@googlegroups.com
Did you import networkx as nx before running that example code?
>>>import networkx as nx

Somehow its not finding networkx.all_shortest_paths
Dan

On Nov 14, 2012, at 5:21 PM, basavesh wrote:

> Hi all,
>
> I'm using networkx for sometime. I wanted to check multipath(shortest paths) from source to target. I tried the example given in http://networkx.lanl.gov/reference/generated/networkx.algorithms.shortest_paths.generic.all_shortest_paths.html#networkx.algorithms.shortest_paths.generic.all_shortest_paths
>
> >>> G=nx.Graph()
> >>> G.add_path([0,1,2])
> >>> G.add_path([0,10,2])
> >>> print([p for p in nx.all_shortest_paths(G,source=0,target=2)])
> [[0, 1, 2], [0, 10, 2]]
> but getting AttributeError: print([p for p in nx.all_shortest_paths(G,source=0,target=2)])
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> AttributeError: 'module' object has no attribute 'all_shortest_paths'
>
>
> please help me in this.
>
> --
> You received this message because you are subscribed to the Google Groups "networkx-discuss" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/networkx-discuss/-/ZRYp1PVat5MJ.
> To post to this group, send email to networkx...@googlegroups.com.
> To unsubscribe from this group, send email to networkx-discu...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/networkx-discuss?hl=en.

Basavesh Shivakumar

unread,
Nov 14, 2012, 6:53:46 PM11/14/12
to networkx...@googlegroups.com
HI Dan,
yes I did import it.
--
Regards,
Basavesh A S
Final year CSE B.Tech
NITK Surathkal

Aric Hagberg

unread,
Nov 14, 2012, 10:20:56 PM11/14/12
to networkx...@googlegroups.com
On Wed, Nov 14, 2012 at 4:53 PM, Basavesh Shivakumar
<basaves...@gmail.com> wrote:
> HI Dan,
> yes I did import it.
>

Maybe you have an old version of NetworkX?
Try
>>> import networkx as nx
>>> print networkx.__version__

The current release is networkx-1.7 http://pypi.python.org/pypi/networkx
Aric

Basavesh Shivakumar

unread,
Nov 15, 2012, 12:46:45 AM11/15/12
to networkx...@googlegroups.com
Hi Aric,
It say networkx 1.6. How can I upgrade to 1.7?
Should I uninstall 1.6 and then install 1.7?? or is there any mechanism to upgrade directly?


--
You received this message because you are subscribed to the Google Groups "networkx-discuss" group.
To post to this group, send email to networkx...@googlegroups.com.
To unsubscribe from this group, send email to networkx-discu...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/networkx-discuss?hl=en.

Basavesh Shivakumar

unread,
Nov 15, 2012, 12:56:56 AM11/15/12
to networkx...@googlegroups.com
problem solved after upgrading to networkx 1.7

Thanks a lot :)

lopezd...@gmail.com

unread,
Jan 8, 2014, 10:30:40 PM1/8/14
to networkx...@googlegroups.com, basavesh kumar
Same with me:

import networkx as nx
G=nx.path_graph(4)
print nx.degree_pearsonr(G)

generates the error: AttributeError: 'module' object has no attribute 'degree_pearsonr'


On Sunday, April 14, 2013 10:55:43 PM UTC-4, babe wrote:
Hi,all
I have the same problem, and update networkx to the latest 1.7, but it still has the error.

>>> import networkx as nx
>>> print nx.__version__
1.7
>>> G = nx.complete_graph(4)
>>> print nx.all_simple_paths(G, source=0, target=3, cutoff=2)

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

thanks for help! 

Aric Hagberg

unread,
Jan 8, 2014, 10:35:25 PM1/8/14
to networkx...@googlegroups.com
It's called "degree_pearson_correlation_coefficient"

In [1]: import networkx as nx

In [2]: G = nx.house_graph()

In [3]: nx.degree_pearson_correlation_coefficient(G)
Out[3]: -0.33333333333333331

Aric
> --
> You received this message because you are subscribed to the Google Groups
> "networkx-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to networkx-discu...@googlegroups.com.
> To post to this group, send email to networkx...@googlegroups.com.
> Visit this group at http://groups.google.com/group/networkx-discuss.
>
> For more options, visit https://groups.google.com/groups/opt_out.
Reply all
Reply to author
Forward
0 new messages