Graph#

Module to handle nx graphs.

class plot_data.graph.NetworkxGraph(graph: Graph, node_radius: float = 0.04, show_edge_name: bool = False, layout: Literal['spring', 'kamada_kawai', 'circular', 'shell', 'spectral', 'planar', 'random', 'spiral', 'bipartite', 'multipartite'] = 'kamada_kawai', name: str = '')[source]#

Bases: PrimitiveGroup

Each node of self.graph can contain its settings in the node.data dictionary.

Keys can be :
  • ‘color’ with format ‘rgb(xr, xg, xb)’, xr, xg, xb are integers between 0 and 255

  • ‘shape’, choose between ‘.’ for Point2D, ‘o’ for Circle2D, ‘s’ for bigger Circle2D

  • ‘name’ with format str

Available layouts:
  • ‘spring’: Fruchterman-Reingold force-directed algorithm

  • ‘kamada_kawai’: Kamada-Kawai force-directed algorithm (default)

  • ‘circular’: Nodes positioned on a circle

  • ‘shell’: Nodes in concentric circles

  • ‘spectral’: Using eigenvectors of graph Laplacian

  • ‘planar’: Without edge intersections (for planar graphs)

  • ‘random’: Uniformly random positions

  • ‘spiral’: Nodes in a spiral pattern

classmethod get_available_layouts() List[Literal['spring', 'kamada_kawai', 'circular', 'shell', 'spectral', 'planar', 'random', 'spiral', 'bipartite', 'multipartite']][source]#

Get a list of all available layout algorithms.

to_plot_data()[source]#

Get the equivalent PlotDataObject.