Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 8 additions & 18 deletions pyvis/source/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -168,27 +168,17 @@ The following code block is a minimal example of the capabilities of pyvis.
got_net.barnes_hut()
got_data = pd.read_csv("../../notebooks/NetworkOfThrones.csv")

sources = got_data['Source']
targets = got_data['Target']
weights = got_data['Weight']

edge_data = zip(sources, targets, weights)

for e in edge_data:
src = e[0]
dst = e[1]
w = e[2]

got_net.add_node(src, src, title=src)
got_net.add_node(dst, dst, title=dst)
got_net.add_edge(src, dst, value=w)

neighbor_map = got_net.get_adj_list()
for src, dst, w in zip(got_data.Source, got_data.Target, got.Weight):
got_net.add_node(src, src, title=src)
got_net.add_node(dst, dst, title=dst)
got_net.add_edge(src, dst, value=w)

# add neighbor data to node hover data
neighbor_map = got_net.get_adj_list()

for node in got_net.nodes:
node["title"] += " Neighbors:<br>" + "<br>".join(neighbor_map[node["id"]])
node["value"] = len(neighbor_map[node["id"]])
node["title"] += " Neighbors:\n" + "\n".join(neighbor_map[node["id"]])
node["value"] = len(neighbor_map[node["id"]])

got_net.show("gameofthrones.html")

Expand Down