ucsd-ccbb / visJS2jupyter

visJS2jupyter is a tool to bring the interactivity of networks created with vis.js into jupyter notebook cells
MIT License
78 stars 17 forks source link

Support Multigraph? #5

Closed kevinxin90 closed 6 years ago

kevinxin90 commented 6 years ago

Wondering if your software supports multigraph display? More specifically, I have a multiple edges connecting two nodes, and each with different label. e.g Nodes(1,2), edges([1,2, {label: 'flower'}], [1,2,{label:'plant'}]). Wondering if your software has a parameter to display this graph without having edges overlapping each other? Thanks!

brinrosenthal commented 6 years ago

This is a good question- unfortunately our tool does not currently support multigraph display. However, there may be a way to display multiple edges by plotting multiple networks on top of each other. We are currently investigating the feasibility of doing this, and hope to have an example notebook posted soon.

Thanks!

kevinxin90 commented 6 years ago

Thanks! Looking forward to that!

brinrosenthal commented 6 years ago

We have added a multigraph example here https://bl.ocks.org/m1webste/raw/db4aeda3f3e4a8840f08182f2e5d4608/

Hope this helps!

kevinxin90 commented 6 years ago

Hi,

Thanks so much for the update!

FYI, there seems some small errors on your example code:

  1. On cell 3 sources = list(zip(*edges)[0]) Looks like it should be: sources = list(zip(*edges))[0]
  2. On cell 7 It seems the dictionary key for 'edge_to_color' is something like (source, target), but what u are feeding is (source, target, key). It will return a key error.

Thanks again!

kevinxin90 commented 6 years ago

Btw, I found 'bl.ocks.org' only allows returning one interactive graph on the html page. However, in our use cases, we need to display multiple interactive graphs on the same HTML page. Wondering if you guys know if there is a way around this? Thanks!

m1webste commented 6 years ago

Hello!

  1. That line of code in cell three should be correct. (In truth the only difference it made for me is that your suggested line produced a tuple instead of a list). But if it is causing any errors for you, please show me!

  2. I believe the the reason you are getting a key error is because you need to update visJS2jupyter to version 0.1.8. Some functions were updated to support multigraphs.

No problem!

brinrosenthal commented 6 years ago

Hi Kevin, unfortunately we haven't found a way to display multiple graphs in bl.ocks.org.