Set the edge layer in pyvis

73 views Asked by At

I would like to have thick edges (black in the image below) on top of thin edges (grey in the image below) in pyvis, is this somehow possible?

enter image description here

import networkx as nx
import numpy as np
from pyvis.network import Network

def rgb_to_hex(r, g, b):
    return '#{:02x}{:02x}{:02x}'.format(r, g, b)

G = nx.complete_graph(20)
net = Network()
net.from_nx(G)

for edge in net.edges:
    random_number = np.random.rand()*0.6 + 0.2
    edge["color"] = rgb_to_hex(int(255 * (1 - random_number)), int(255 * (1 - random_number)), int(255 * (1 - random_number)))
    edge["width"] = int(4 * random_number)

net.toggle_physics(False)
net.save_graph("test.html")
0

There are 0 answers