Interactive graph visualization application

class cord19kg.apps.visualization_app.VisualizationApp(configs=None)

JupyterDash-based interactive graph visualization app.

add_graph(graph_id, graph, tree=None, positions=None, default_top_n=None, full_graph_view=False)

Set a graph to display.

Parameters:
  • graph_id (str) – Graph identifier to use in the app

  • graph_object (PandasPGFrame) – Input graph object

  • tree_object (PandasPGFrame, optional) – Pre-computed minimum spanning tree object

  • positions (dict, optional) – Dictionary containing pre-computed node positions

  • default_top_n (int, optional) – Top n entities to display by default

  • full_graph_view (bool, optional) – Flag indicating whether the current graph should be displayed as a spanning tree or entirely (spanning tree is shown by default)

export_graphs(graph_list)

Export current graph objects from the app.

Parameters:

graph_list (list of str) – List of graph identifiers to export

Returns:

graphs – Dictionary whose keys represent the input list of graph identifiers to export. Eeach graph is given by a dictionary with two keys: graph giving the full graph object and tree giving the minimum spanning tree object.

Return type:

dict

get_configs()

Get current app configs.

get_edit_history()

Export the history of graph edits.

run(port, mode='jupyterlab', debug=False, inline_exceptions=False)

Run the graph visualization app.

Parameters:
  • port (int) – Port number to launch the app (localhost:<port>).

  • mode (str, optional) – Mode in which the app should be launched. Possible values: inline inside the current Jupyter notebook, external given an external link that can be opened in a browser, jupyterlab as a new tab of JupyterLab.

  • debug (bool, optional) – Flag indicating whether the app is launched in the debug mode (traceback will be printed).

  • inline_exceptions (bool, optional) – Flag indicating whether app exceptions should be printed in the current active notebook cell.

set_aggregated_entities_callback(func)

Set the aggegated entities lookup callback.

This function will be called when the user requests to see a set of raw entities associated with a selected node. The visualization app will pass the selected entity to this function. The function is expected to return a dictionary whose keys are raw entities and whose values are their occurrence frequencies.

set_backend(backend)

Set graph processing backend (currently, ‘networkx’ or ‘graph_tool’).

set_current_graph(graph_id)

Set current graph.

Parameters:

graph_id (str) – Graph identifier to set as the current graph.

set_entity_definitons(definition_dict)

Set the lookup dictionary for entity definitions.

set_list_papers_callback(func)

Set the paper lookup callback.

This function will be called when the user requests to see a list of papers associated with a selected node or an edge. The visualization app will pass the list of paper indentifiers to this function. The function is expected to return a list of dictionaries each representing a paper’s meta-data.

cord19kg.apps.visualization_app.top_n_subgraph(graph_processor, n, node_subset=None, nodes_to_keep=None)

Build a subgraph with top n nodes.