networkit.vizbridges

class networkit.vizbridges.Dimension(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

Supported dimensions for visualization.

Possible values:

  • networkit.vizbridges.Dimension.Two (visualization in 2D with Cytoscape)

  • networkit.vizbridges.Dimension.TwoForcePlotly (visualization in 2D with Plotly)

  • networkit.vizbridges.Dimension.Three (visualization in 3D with Plotly)

networkit.vizbridges.widgetFromGraph(G, dimension=Dimension.Two, nodeScores=None, nodePartition=None, nodePalette=None, showIds=True, customSize=None, edgeScores=None, edgePalette=None)

Creates a widget with a visualization of a given graph. The widget uses one of the supported plugins - either Cytoscape (2D) or Plotly (3D). The returned widget already contains all nodes and edges from the graph. The graph is colored using an array of norm. rgb-values based on seaborn perceptually uniform color map (rocket) or a user given custom color array. See matplotlib color maps for the correct formatting: https://matplotlib.org/api/_as_gen/matplotlib.colors.Colormap.html#matplotlib.colors.Colormap

Parameters:
  • G (networkit.graph.Graph) – The input graph.

  • dimension (networkit.vizbridges.Dimension, optional) – Select whether to plot in 2D or 3D. This also influences which plugin is choosen for visualization. For 2D Cytoscape with auto-layouting is used, for 3D Plotly with a Maxent-Stress layout is used. Option Dimension.TwoForcePlotly forces a plot in 2D with using Plotly instead of Cytoscape. Default: networkit.vizbridges.Dimension.Two

  • nodeScores (list(float) or dict, optional) – List of scores for each node, for example scores from a centrality measure. This is used for color-calculation of the nodes (continuous distribution). Provide either nodeScores or nodePartition - not both. Default: None

  • nodePartition (networkit.structures.Partition, optional) – Partition object. This is used for color-calculation of the nodes (discrete distribution). Provide either nodeScores or nodePartition - not both. Default: None

  • nodePalette (list(tuple(float, float, float)), optional) – List consisting of normalized rgb-values. If none is given, seaborn.color_palette.colors is used. Default: None

  • showIds (boolean, optional) – Set whether node ids should be visible in plot-widget. Default: True

  • customSize (int, optional) – If not set, plugins will use a default size. Otherwise the widget will have a certain width and height. Default: None

  • edgeScores (list(float) or dict, optional) – List of scores for each edge, for example scores from a centrality measure. This is used for color-calculation of the edges (continuous distribution). If type is list, indexed by edgeids; if type is dict, indexed by node pair tuples. Default: None

  • edgePalette (list(tuple(float, float, float)), optional) – List consisting of normalized rgb-values. If none is given, seaborn.color_palette.colors is used. Default: None

  • edgeAttributes (list[tuple[str, type]], optional) – List consisting of all (already attached) edge attributes in the format: Tuple(nameOfAttribute, typeOfAttribute) that will be presented as edge labels. Default: None