Networkx integration issues - updating and saving

Hey!

I’m currently working on an annotating system using bokeh and have 2 issues regarding working with network graphs.

I’m using from_networkx to create a network graph plot and I’m updating it with respect to what the user annotated.

  1. when I’m renaming node indices and updating - the node disappears
change_label_name_button.js_on_click(CustomJS(
    args=dict(
        data_src=label_data.data_src, output=label_data.output_data,
        table_data=label_data.table_data,
        selected_label=change_label_selector, new_label=change_label_input,
        graph_src = label_data.network_graph.node_renderer.data_source, output_graph = output_graph_data,
        edges=label_data.network_graph.edge_renderer.data_source, output_edges = output_edges_data,
        graph_src=label_data.network_graph, output_graph=label_data.output_graph,
        new_classes=[], select_label_selector=select, is_new_label = is_new_label_checkbox),
    code=('''
        for (var i =0; i<graph_src.data['index'].length;i++) {
            output_graph.data['index'][i] = graph_src.data['index'][i] === selected_label.value ? new_label.value : graph_src.data['index'][i]
        }
        for (var i=0; i<edges.data['end'].length;i++) {
            output_edges.data['end'][i] = edges.data['end'][i] === selected_label.value ? new_label.value : edges.data['end'][i]
        }
        for (var i=0; i<edges.data['start'].length;i++) {
            output_edges.data['start'][i] = edges.data['start'][i] === selected_label.value ? new_label.value : edges.data['start'][i]
        }
    
        graph_src.data = output_graph.data
        edges.data = output_edges.data
        
        graph_src.change.emit()
        edges.change.emit()
'''
) 
  1. I was wondering if there’s a way to retrieve the new structure I created on the graph. meaning the opposite action of from_networkx. I want to save the output graph inside a pickle (or any other file in that manner).

thanks a lot!

Amit.

HI @amitsandhel please edit your post to use code formatting so that the code is intelligible (either with the </> icon on the editing toolbar, or triple backtick ``` fences around the code blocks)

1 Like

Hey!
@Bryan sorry, edited :slight_smile:

No there is nothing built-in that would do that. Bokeh only knows how to ingest NetworkX.

For the first question there is not much that can be said without a complete Minimal Reproducible Example to run and investigate directly. If I were debugging the first thing I would do would be to add some console.log statements to inspect the data that is getting set and make sure it is what I expect it to be.

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