Created
July 7, 2020 22:30
-
-
Save stanlee321/512c6cd7c59228953a50c0ced7730e4c to your computer and use it in GitHub Desktop.
graphs example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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