Using pyvis and other javascript wrappers in Zeppelin

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Using pyvis and other javascript wrappers in Zeppelin

David Boyd

    Googled this problem but have not found a solution that works.

I am trying to use pyvis to generate interactive network graphs.
The pyvis functions output an HTML file.   I have tried several approaches
but not found anything that works for something that should be simple.

Here is my sample code:

> %ipython
> from import Network
> from IPython.display import HTML
> import networkx as nx
> import os
> nx_graph = nx.cycle_graph(10)
> nx_graph.nodes[1]['title'] = 'Number 1'
> nx_graph.nodes[1]['group'] = 1
> nx_graph.nodes[3]['title'] = 'I belong to a different group!'
> nx_graph.nodes[3]['group'] = 10
> nx_graph.add_node(20, size=20, title='couple', group=2)
> nx_graph.add_node(21, size=15, title='couple', group=2)
> nx_graph.add_edge(20, 21, weight=5)
> nx_graph.add_node(25, size=25, label='lonely', title='lonely node',
> group=3)
> nt = Network("500px", "500px",notebook=True)
> # populates the nodes and edges data structures
> nt.from_nx(nx_graph)
> nt.prep_notebook()
> file = open("/tmp/nx.html")
> HTML(htmldata)
So I was able to get this to work.
But if I have a subsequent note paragraph to display a different
graph the graph in the first note is overwritten.

Surely there is a better approach and I am looking for suggestions
on approaches and ways to get multiple graphs to display.

========= mailto:[hidden email] ============
David W. Boyd
VP,  Data Solutions
10432 Balls Ford, Suite 240
Manassas, VA 20109
office:   +1-703-552-2862
cell:     +1-703-402-7908
============== ============
ISO/IEC JTC1 SC42/WG2, editor ISO/IEC 20546, ISO/IEC 20547-1
Chair INCITS TG Big Data
Co-chair NIST Big Data Public Working Group Reference Architecture
First Robotic Mentor - FRC, FTC -
Board Member- USSTEM Foundation -

The information contained in this message may be privileged
and/or confidential and protected from disclosure.
If the reader of this message is not the intended recipient
or an employee or agent responsible for delivering this message
to the intended recipient, you are hereby notified that any
dissemination, distribution or copying of this communication
is strictly prohibited.  If you have received this communication
in error, please notify the sender immediately by replying to
this message and deleting the material from any computer.