How do I display edge labels for a graph

Hello,

I would like to display labels for the edges of my network graph.

What would be the easiest way to do that?

Below you can see a small graph with two nodes and one connecting edge as an example. I prepared a test label for the only edge in a dictionary form.

Thanks in advance for any help.

import numpy as np
import holoviews as hv
hv.extension('bokeh')

def main():    

	# create a graph with two nodes and one connecting edge 
	node_indices = np.arange(2, dtype=np.int32)
	source = np.zeros(2, dtype=np.int32)
	target = node_indices
	graph = hv.Graph(((source, target),))
	
	# edge labels to be set: 
	edge_label = {(0,1): "test label"}
	
	# save the graph
	hv.save(graph, 'graph.html', backend='bokeh')
	return

if __name__ == '__main__':
    main()

1 Like