NetworkX graphs can be directly added to a canvas in the following way:
import networkx as nx from algorithmx.networkx import add_graph G = nx.MultiDiGraph() G.add_nodes_from([1, 2, 3]) G.add_weighted_edges_from([(1, 2, 3.0), (2, 3, 7.5)]) # canvas = ... add_graph(canvas, G)
add_graph(canvas: algorithmx.graphics.CanvasSelection.CanvasSelection, graph, weight: Optional[str] = 'weight') → algorithmx.graphics.CanvasSelection.CanvasSelection¶
CanvasSelection) – The CanvasSelection onto which the graph should be added.
graph (Any type of NetworkX graph) – The NetworkX graph
weight (Union[str, None]) – The name of the attribute which describes edge weight in the the NetworkX graph. Edges without the attribute will not display a weight, and a value of
Nonewill prevent any weight from being displayed. Defaults to “weight”.
The provided CanvasSelection with animations disabled, allowing initial attributes to be configured.
- Return type