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.

Does not work with MultiGraph

See original GitHub issue
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

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:2
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Zsailercommented, 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?

0reactions
ceciliazzzzzzcommented, Apr 13, 2021

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

FindCycle not working as expected for multigraph
I presume Mathematica searches for "simple cycles," i.e., no repetitions of vertexes, even though the EulerianCycle is somehow found. · Note too: ...
Read more >
Multigraph - Wikipedia
In mathematics, and more specifically in graph theory, a multigraph is a graph which is permitted to have multiple edges (also called parallel...
Read more >
MultiGraph—Undirected graphs with self loops and parallel ...
By convention None is not used as a node. Edges are represented as links between nodes with optional key/value attributes, in a MultiGraph...
Read more >
NetworkX multigraph plot does not show labels - Stack Overflow
Here is how you can add edge labels to your graph: import pandas as pd import networkx as nx from matplotlib import pyplot...
Read more >
Extremal problems for multigraphs - ScienceDirect
More recently, Mubayi and Terry (2019) [13] posed the problem of determining the maximum of the product of the edge multiplicities in (...
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