enthought / enthought/graphcanvas

Cannot create `GraphView` : `graph_from_dict` KeyError

Open
#34 0 comments 0 reactions 1 assignee Claimed by @stevenjkern View on GitHub
Dominant language
Python
Stars
26
Forks
8
PR merge metrics
No merged PRs in 30d

Description

The README example fails with a `KeyError`:

```python
>>> 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 "", line 1, in
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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.