Calling from_networkx using a graph with string nodes


I am trying to incorporate bokeh into a project I am working on. I currently have networkx graphs where the nodes keys are strings. Calling from_networkx with the graph raises an error failed to validate StaticLayoutProvider(id='p1072', ...).graph_layout: expected an element of Dict(Int, Seq(Any), which originates in this line bokeh/ at branch-3.1 · bokeh/bokeh · GitHub
I tried changing the typing check to Dict(Any, Seq(Any)), but this causes the code to not display anything at all.
Minimal reproducible example:

import networkx as nx

from bokeh.plotting import figure, from_networkx
from networkx.drawing.nx_agraph import graphviz_layout
G = nx.Graph()
G.add_node("A node")
from_networkx(G, nx.spring_layout)

Is there an option to easily bypass this? Or I need to change my graph to work with integers (which is a bit of a headache for me)


Bokeh graph renderers currently expect integer node indices to be used.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.