On , Ryan Acumen <
ryan....@gmail.com> wrote:
> When I try to draw a graph I've created from a file in this manner:
> >>> import networkx as nx
> >>> G = nx.Graph()
> >>> prod_parse(G,'/home/acumen/Programs/diode.prod')
> >>> nx.draw(G)
>
> I get this error:
> Traceback (most recent call last):
> File "", line 1, in
> nx.draw(G)
> File "/usr/lib/python2.7/site-packages/networkx-1.7-py2.7.egg/networkx/drawing/nx_pylab.py", line 133, in draw
> draw_networkx(G,pos=pos,ax=ax,**kwds)
> File "/usr/lib/python2.7/site-packages/networkx-1.7-py2.7.egg/networkx/drawing/nx_pylab.py", line 264, in draw_networkx
> pos=nx.drawing.spring_layout(G) # default to spring layout
> File "/usr/lib/python2.7/site-packages/networkx-1.7-py2.7.egg/networkx/drawing/layout.py", line 236, in fruchterman_reingold_layout
> A=nx.to_numpy_matrix(G,weight=weight)
> File "/usr/lib/python2.7/site-packages/networkx-1.7-py2.7.egg/networkx/convert.py", line 524, in to_numpy_matrix
> M[index[u],index[v]]=d.get(weight,1)
> AttributeError: 'float' object has no attribute 'get'
>
> Here is my code to build the graph:
> for i in e1:
> t = i.split(',')
> edges += [(t[0],t[1],float(t[2]))]
> #convert attributes
> for i in a1:
> t = i.split(',')
> attributes += [[t[0],t[1],float(t[2])]]
> #build graph
> G.add_nodes_from(nodes)
>
> I have verified that the edge tuples are structured correctly, at least to my understanding:
> edges: [('Diode', 'Die', 0.000717646120724),('Diode', 'Case', 0.465672593892),('Diode', 'Lead Frame', 0.498684315445),('Diode', 'Die Attach', 0.0318156446854),('Diode', 'Plating', 0.00310979985647),('Die', 'Silicon', 1.0),('Case', 'Silica', 0.865),('Case', 'Epoxy', 0.07),('Case', 'Aluminum Hydroxide', 0.015),('Case', 'Bisphenol A', 0.05),('Lead Frame', 'Copper', 1.0),('Die Attach', 'Lead', 0.925),('Die Attach', 'Gold', 0.025),('Die Attach', 'Tin', 0.05),('Plating', 'Tin', 1.0)]
>
> I'm sure the error is on my end. Anyone know what my problem may be?
>
>
>
>
>
> --
>
> 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/-/s6FEKxu311cJ.
>
> 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.
>
>
>
>