To plot the graph, I use the following code:
from pyvis.network import Network
import csv
got_net = Network(height='900px', width='100%', bgcolor='#222222', font_color='white')
got_net.barnes_hut()
with open('test.csv', 'r') as csvfile:
spamreader = csv.reader(csvfile, delimiter=';')
for row in spamreader:
id_, channel, message = row
src = str(id_)
dst = str(channel)
msg = str(message)
got_net.add_node(src, src, title="ID: " + src, size=5)
got_net.add_node(dst, dst, title="Channel: " + dst, size=10,
physics=False, shape='triangle')
got_net.add_edge(src, dst, label=msg)
got_net.force_atlas_2based()
got_net.show_buttons(filter_=True)
got_net.show('./test.html')
I get the result:
But when I try to change the color of the edge of the graph, it doesn't work:
Could you tell me please, what am I doing wrong? What do I need to do to make the edges also have a different color when they are selected? Thank you.
my csv file:
I managed to find a solution, in my case, when constructing an edge
, you must specify the following:
color=dict(highlight={'background': 'red'})
final version:
got_net.add_edge(src, dst, label=msg, color=dict(highlight={'background': 'red'}))