As a starting point, here's a script to convert that dictionary into a networkx graph, with the nodes and edges labeled correctly. Each pair of nodes has the correct number of edges connecting them.
from collections import defaultdict as dd
d = {
"Rack_01" : [1, 2, 3],
"Rack_02" : [3, 4, 5],
"Rack_03" : [1, 2, 4, 5],
}
m = len(d) #number of nodes
edge_set = set([i for v in d.values() for i in v])
n = len(edge_set) # number of edges
edge_label = dict(enumerate(edge_set))
node_label = dict(enumerate(d))
# number
inc_mat = np.array([[edge_label[j] in d[label[i]]
for j in range(n)]
for i in range(m)],dtype=int)
adj_mat = np.zeros((m,m),dtype=int)
nodes_to_edge = dd(list)
for k,col in enumerate(inc_mat.T):
i,j = np.nonzero(col)[0]
adj_mat[[i,j],[j,i]]+=1
nodes_to_edge[(i,j)].append(edge_label[k])
G = nx.from_numpy_array(adj_mat, parallel_edges=True,create_using=nx.MultiGraph)
for u,v,d in G.edges(data=True):
d['label'] = nodes_to_edge[(u,v)].pop()
nx.relabel_nodes(G,node_label,copy=False)
From there, you could use the answer here to generate your visualization.
The result of print(G.edges(data=True))
, for reference:
[('Rack_01', 'Rack_02', {'weight': 1, 'label': 3}), ('Rack_01', 'Rack_03', {'weight': 1, 'label': 2}), ('Rack_01', 'Rack_03', {'weight': 1, 'label': 1}), ('Rack_02', 'Rack_03', {'weight': 1, 'label': 5}), ('Rack_02', 'Rack_03', {'weight': 1, 'label': 4})]