import pandas as pd
import graphistry

# 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: How to pass in layout positions to the visualization

Add x, y columns to the node table
Add the url parameter "play=0" to prevent the page load to run clustering.
End of explanation
"""


edges = pd.DataFrame({'s': [0,1,2, 3], 'd': [1,2,3, 0]})
nodes = pd.DataFrame({'n': [0,1,2, 3], 'x': [0, 0, 1, 1], 'y': [0, 5, 5, 0]})

"""
Explanation: 1. Nodes should have columns "x", "y"
End of explanation
"""


graphistry\
    .settings(url_params={'play': 0})\
    .nodes(nodes).edges(edges)\
    .bind(source='s', destination='d', node='n')\
    .plot()

"""
Explanation: 2. The bindings should include ".settings(url_params={'play': 0})"
End of explanation
"""


