Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not work with MultiGraph #13

Open
poglesbyg opened this issue Mar 23, 2019 · 6 comments
Open

Does not work with MultiGraph #13

poglesbyg opened this issue Mar 23, 2019 · 6 comments

Comments

@poglesbyg
Copy link

G1 = nx.MultiGraph()
G1.add_nodes_from(nodes)
G1.add_edges_from(edges)
print(nx.info(G1))

Name:
Type: MultiGraph
Number of nodes: 194
Number of edges: 222
Average degree: 2.2887

nx.draw_spring(G1)
pos = nx.spring_layout(G1)

This will print a graph using just NetworkX, but when I try to pass it into nx_altair like this:

nxa.draw_networkx(
    G=G2, pos=pos)

I get this error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-23-d3bff3e27cba> in <module>
      2 
      3 nxa.draw_networkx(
----> 4     G=G2, pos=pos)

~/miniconda3/envs/genes/lib/python3.7/site-packages/nx_altair/draw_altair.py in draw_networkx(G, pos, chart, nodelist, edgelist, node_size, node_color, node_label, font_color, font_size, alpha, cmap, width, arrow_width, arrow_length, edge_color, arrow_color, node_tooltip, edge_tooltip, edge_cmap)
    630             edge_color=edge_color,
    631             edge_cmap=edge_cmap,
--> 632             tooltip=edge_tooltip,
    633             )
    634 

~/miniconda3/envs/genes/lib/python3.7/site-packages/nx_altair/draw_altair.py in draw_networkx_edges(G, pos, chart, layer, edgelist, width, alpha, edge_color, edge_cmap, tooltip, legend, **kwargs)
     58     if chart is None:
     59         # Pandas dataframe of edges
---> 60         df_edges = to_pandas_edges(G, pos)
     61 
     62         # Build a chart

~/miniconda3/envs/genes/lib/python3.7/site-packages/nx_altair/core.py in to_pandas_edges(G, pos, **kwargs)
     37     attributes = ['source', 'target', 'x', 'y', 'edge', 'pair']
     38     for e in G.edges():
---> 39         attributes += list(G.edges[e].keys())
     40     attributes = list(set(attributes))
     41 

~/miniconda3/envs/genes/lib/python3.7/site-packages/networkx/classes/reportviews.py in __getitem__(self, e)
   1104 
   1105     def __getitem__(self, e):
-> 1106         u, v, k = e
   1107         return self._adjdict[u][v][k]
   1108 

ValueError: not enough values to unpack (expected 3, got 2)
 

I'd like to use your library to interact with and visualize this multigraph that I'm working with. Is this already possible, or is this a new feature that needs to be implemented?

Thanks,
Paul

@Zsailer
Copy link
Owner

Zsailer commented Jul 25, 2019

Hi Paul, sorry for the delayed reply here. I'm catching up on issues here...

It looks like we'll need to add a new feature to handle MultiGraph objects. Would you be interested in trying to add this feature to the library?

@njss
Copy link

njss commented Oct 16, 2019

I have no idea how to do it... however this would be great...

@RMKD
Copy link

RMKD commented Oct 17, 2019

I'm seeing this too. I can take a look if no one has started work on it yet

@Zsailer
Copy link
Owner

Zsailer commented Oct 17, 2019

@RMKD go for it! I'm happy to review the PR. Thanks!

@Falkonry-deeksha
Copy link

I am facing similar issue. Is the new feature available for use ?

@ceciliazzzzzz
Copy link

Same error here, any updates to catch up with?
in getitem
u, v, k = e
not enough values to unpack (expected 3, got 2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants