question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AttributeError: 'NodeView' object has no attribute 'index'

See original GitHub issue
  • nxviz version: 0.3.2
  • Python version: 3.6.3
  • Operating System: Windows 7 Enterprise Service Pack 1
  • Using the Jupyter Notebook in Anaconda

Description

When attempting to make any CircosPlot from a NetworkX 2.0 Graph object, I get the following error: “AttributeError: ‘NodeView’ object has no attribute ‘index’”. Does this have something to do with NetworkX 2.0 compatibility? I’ve updated nxviz to the latest github version which lists NetworkX 2.0 in the requirements, so I’m confused as to what’s causing this.

What I Did

Here’s an example with a random graph.

G3 = nx.Graph()
G3.add_nodes_from(range(10))
G3.add_edges_from([(0,1), (0,3), (2,4), (1,2), (2,7), (0,9), (5,6), (3,8), (1,9), (4,8)])
c3 = CircosPlot(G3)

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-18-97dd4ee1b584> in <module>()
----> 1 c3 = CircosPlot(G3)

~\AppData\Local\Continuum\anaconda3\lib\site-packages\nxviz\plots.py in __init__(self, graph, node_order, node_size, node_grouping, node_color, edge_width, edge_color, data_types, nodeprops, edgeprops)
    245                           node_color=node_color, edge_width=edge_width,
    246                           edge_color=edge_color, data_types=data_types,
--> 247                           nodeprops=nodeprops, edgeprops=edgeprops)
    248 
    249     def compute_node_positions(self):

~\AppData\Local\Continuum\anaconda3\lib\site-packages\nxviz\plots.py in __init__(self, graph, node_order, node_size, node_grouping, node_color, edge_width, edge_color, data_types, nodeprops, edgeprops)
    122 
    123         # Compute each node's positions.
--> 124         self.compute_node_positions()
    125 
    126     def check_data_types(self, data_types):

~\AppData\Local\Continuum\anaconda3\lib\site-packages\nxviz\plots.py in compute_node_positions(self)
    259         self.nodeprops['linewidth'] = radius * 0.01
    260         for node in self.nodes:
--> 261             x, y = get_cartesian(r=radius, theta=node_theta(self.nodes, node))
    262             xs.append(x)
    263             ys.append(y)

~\AppData\Local\Continuum\anaconda3\lib\site-packages\nxviz\geometry.py in node_theta(nodelist, node)
     19     assert node in nodelist, 'node must be inside nodelist.'
     20 
---> 21     i = nodelist.index(node)
     22     theta = -np.pi + i*2*np.pi/len(nodelist)
     23 

AttributeError: 'NodeView' object has no attribute 'index'

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
basselhakcommented, Nov 7, 2017

Hi @ericmjl ,

Here’s the latest version of the network analysis: https://nbviewer.jupyter.org/github/basselhak/braindrain/blob/organizations/brain_drain_politics_organizations.ipynb

I only do a quick visualization with nxviz before moving on to doing the rest in matplotlib, because I need labels for now. Once we get labels working, I think I could update the notebook to do a more extended visualization in nxviz and then you could tweet that as an example of how to use your package, if you like.

If you have any comments or suggestions on the code as it stands now, using matplotlib, feel free to let me know. And thanks for being responsive on the nxviz issues. I really like the package and hope to see it expanded in the future.

Best, Jacob

0reactions
musaahmedcommented, Jul 15, 2019

please the same error is occured ,after running the following code segments in network graph analysis:full package is on github import DBCP as dp import Evaluation as eva

#the function of “Find_Controller_Placement” has three parameters: #1. graph_url is the file name of graph; #2. avg_weight is the weight to select the placement according to the objective function of average controller-to-switch latency; #3. max_weight is the weight to select the placement according to the objective function of worst-case controller-to-switch latency; #4. inter_weight is the weight to select the placement according to the objective function of average inter-controller latency; #In this demo, we only consider average latency and worst-case latency.

#the eva class has three function can be used. They are: #1. Avg_latency_of_end_to_end(graph_name,controller_list), it can measure the average latency of end-to-end communications; #2. Avg_latency_of_inter_controller(graph_name,controller_list), it can measure the average latency of inter-controller communications; #3. Worst_latency_of_controller_to_switch(graph_name,controller_list), it can measure the worst-case controller-to-switch communciations.

graph_name = ‘Biznet.graphml’ ctl_list dp.Find_Controller_Placement(graph_name,avg_weight=1.0,max_weight=1.0,inter_weight=1.0)

avgL = eva.Avg_latency_of_end_to_end(graph_name,ctl_list) print (‘the average latency of end-to-end communications is’,avgL)

Read more comments on GitHub >

github_iconTop Results From Across the Web

AttributeError: 'NodeView' object has no attribute 'index'
When you ask a list for the index of a particular element it performs a linear search from the beginning to find the...
Read more >
Networkx报错AttributeError: 'NodeView' object has no attribute ...
1:node >>> import networkx as nx >>> G=nx.Graph() >>> G.add_node(1) >>> G.add_nodes_form([2,5]) Traceback (most recent call last): File "<stdin ...
Read more >
networkx.classes.graph — NNGT 1.2.0 documentation
Documentation for the python module NNGT, aimed at describing neuronal networks and interfacing them with simulators.
Read more >
Migration guide from 1.X to 2.0 - NetworkX
Migration guide from 1.X to 2.0#. This is a guide for people moving from NetworkX 1.X to NetworkX 2.0. Any issues with these...
Read more >
索引:“NodeView”对象没有属性“”AttributeError“” - 腾讯云
OG.nodes().index(source_id)) AttributeError: 'NodeView' object has no attribute 'index' 复制. 事实上,以下两行代码:.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found