Skip to content

Cannot create GraphView : graph_from_dict KeyError #34

@Corwinpro

Description

@Corwinpro

The README example fails with a KeyError:

>>> from graphcanvas.api import GraphView, graph_from_dict
>>> g = {'a':['b'], 'b':['c', 'd'], 'c':[], 'd':[]}
>>> GraphView(graph=graph_from_dict(g))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/pkungurtsev/.edm/envs/env/lib/python3.6/site-packages/graphcanvas/graph_view.py", line 75, in __init__
    if isinstance(self.graph.nodes()[0], HasTraits):
  File "/Users/pkungurtsev/.edm/envs/env/lib/python3.6/site-packages/networkx/classes/reportviews.py", line 178, in __getitem__
    return self._nodes[n]
KeyError: 0
>>> import networkx
>>> networkx.__version__
'2.4'
>>> import graphcanvas
>>> graphcanvas.__version__
'4.1.0'

I think this is because networkx.NodeView is essentially a dict so no element-based access is possible.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions