Skip to content

Instantly share code, notes, and snippets.

@stanlee321
Created July 7, 2020 22:30
Show Gist options
  • Save stanlee321/512c6cd7c59228953a50c0ced7730e4c to your computer and use it in GitHub Desktop.
Save stanlee321/512c6cd7c59228953a50c0ced7730e4c to your computer and use it in GitHub Desktop.
graphs example
from pyvis.network import Network
g = Network(height="750px",
width="80%", directed=True)
g.toggle_hide_edges_on_drag(True)
size_pos = len(list(dfs["DATOS DEL POSITIVO"]["NOMBRRE_COMPLETO"]))
size_cont = len(list(dfs["DATOS DEL CONTACTO"]["NOMBRRE_COMPLETO"]))
g.add_nodes(list(dfs["DATOS DEL POSITIVO"]["NOMBRRE_COMPLETO"]),
color=["red"]*size_pos)
g.add_nodes(list(dfs["DATOS DEL CONTACTO"]["NOMBRRE_COMPLETO"]),
color=["blue"]*size_cont)
infected = list(dfs["DATOS DEL POSITIVO"]["NOMBRRE_COMPLETO"])
contacts = list(dfs["DATOS DEL CONTACTO"]["NOMBRRE_COMPLETO"])
for inf, cont in zip(infected, contacts):
g.add_edge(inf, cont, value=0.2)
all_nodes = list(dfs["DATOS DEL POSITIVO"]["NOMBRRE_COMPLETO"]) + list(dfs["DATOS DEL CONTACTO"]["NOMBRRE_COMPLETO"])
g.show_buttons(filter_=['physics'])
g.show("GRAPH_CONTACTS.html")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment