# ! pip install -q --user graphistry pandas

# Sometimes also need to install a new system Excel parser, and pass in as `graphistry.nodexl(..., engine='openpyxl')
# pip install -q --user openpyxl

"""
Explanation: NodeXL <> Graphistry Converter
Now you can explore the results of your NodeXL data workflows with Graphistry GPU visuals!

Takes a url to a NodeXL .xls file (you can upload to your Colab session as well) and creates a live Graphistry viz
Creates a function graphistry.nodexl('http://my_url/file.xls').plot(), see calls to it at the bottom
You can also specify the data source for more bindings, verbose to watch progress, and which Pandas-ready Excel engine: graphistry.nodexl('http://my_url/file.xls', 'twitter', engine='xlrg', verbose=True)
Can upload an XLS file here too, see file upload menu on left (file will be "./my_file.xls")
Click graphistry logo to start a session or right-click to open in a new window and save its url
Rerun cells top-to-bottom by hitting shift-enter

Installs, imports, & creds
First run (non-Graphistry distributions)
You may need to restart your notebook's Python runtime after
End of explanation
"""


import pandas as pd
import graphistry
graphistry.__version__

# To specify Graphistry account & server, use:
# graphistry.register(api=3, username='...', password='...', protocol='https', server='hub.graphistry.com')
# For more options, see https://github.com/graphistry/pygraphistry#configure

"""
Explanation: Imports & credentials
End of explanation
"""


#g = NodeXLGraphistry().xls(xls, 'twitter')
g = graphistry.nodexl('https://nodexlgraphgallery.org/Pages/Workbook.ashx?graphID=220232')

print('%s nodes, %s edges' % (len(g._nodes), len(g._edges)))
g._nodes.sample(2)

g.plot()

"""
Explanation: Sample use
End of explanation
"""


graphistry.nodexl('https://nodexlgraphgallery.org/Pages/Workbook.ashx?graphID=220055', 'twitter', verbose=True).plot()

"""
Explanation: Twitter Demos
Debate Warren
End of explanation
"""


graphistry.nodexl('https://nodexlgraphgallery.org/Pages/Workbook.ashx?graphID=219924', 'twitter', verbose=True).plot()

"""
Explanation: CES Samsung
End of explanation
"""


graphistry.nodexl('https://www.nodexlgraphgallery.org/Pages/Workbook.ashx?graphID=220124', 'twitter', verbose=True).plot()

"""
Explanation: Larger Graph
End of explanation
"""


graphistry.nodexl('https://nodexlgraphgallery.org/Pages/Workbook.ashx?graphID=203001', 'mediawiki').plot()

"""
Explanation: MediaWiki Demos
Demo 1
End of explanation
"""


