Dynamic Edges in Graphs (Python and PyVis Tutorial 12)

Опубликовано: 21 September 2026
на канале: Python Tutorials for Digital Humanities
6,485
82

New JSON File: https://drive.google.com/file/d/1vksk...
Updated Code:
def map_data(letter_data, ep_color="#03DAC6", ms_color="#da03b3", edge_color="#018786", ep_shape="triangle", ms_shape="box", alg="barnes", buttons=False, recipient_color="#FFA300", recipient_shape="ellipse", cited_color="#DFEE9A", cited_shape="square"):
g = Network(height="1500px", width="100%", bgcolor="#222222", font_color="white", directed=True)
g.add_node("Alcuin 1", color="#EB9090")
if buttons==True:
g.width = "75%"
g.show_buttons(filter_=["edges"])
for letter in letter_data[0:10]:
ep = (letter["ep_num"])[0]
mss = (letter["mss"])
recipients = (letter["recipients"])
people_cited = (letter["people_cited"])
g.add_node(ep, color=ep_color, shape=ep_shape)
g.add_edge("Alcuin 1", ep, color=edge_color)
for ms in mss:
g.add_node(ms, color=ms_color, shape=ms_shape)
g.add_edge(ep, ms, color=edge_color)
for recipient in recipients:
g.add_node(recipient, color=recipient_color, shape=recipient_shape)
g.add_edge(ep, recipient, color=recipient_color)
g.add_edge("Alcuin 1", recipient, color="#EB9090")
for cited in people_cited:
if "Alcuin 1" not in cited:
g.add_node(cited, color=recipient_color, shape=recipient_shape)
g.add_edge(ep, cited, color=cited_color)

map_algs(g, alg=alg)
g.set_edge_smooth("dynamic")

If you enjoy this video, please subscribe. I provide all my content at no cost. If you want to support my channel, please donate via
PayPal: https://www.paypal.com/cgi-bin/webscr...
Patreon:   / wjbmattingly   (its my www.themedievalworld.com account as well).

If there's a specific video you would like to see or a tutorial series, let me know in the comments and I will try and make it.

If you liked this video, check out www.PythonHumanities.com, where I have Coding Exercises, Lessons, on-site Python shells where you can experiment with code, and a text version of the material discussed here.