plot_graph¶

plot_graph(canvas, nodes, edges, node_colors=(255, 0, 0), node_size=5, edge_colors=(0, 0, 0), edge_size=5)[source]¶

Drawing a graph onto a canvas.

Drawing a graph onto a canvas.

Parameters:
  • canvas (np.ndarray) – Canvas to be drawn upon.

  • nodes (np.ndarray) – List of nodes, expected to be Nx2 where N is the number of nodes. Each node is expected to be of (x, y) and should be within the height and width of the canvas.

  • edges (np.ndarray) – List of edges, expected to be Mx2 where M is the number of edges. Each edge is defined as a pair of indexes (from, to), where each corresponds to a node of within nodes.

  • node_colors (tuple or np.ndarray) – A color or list of node colors. Each color is expected to be (r, g, b) and is between 0 and 255.

  • edge_colors (tuple or np.ndarray) – A color or list of node colors. Each color is expected to be (r, g, b) and is between 0 and 255.

  • node_size (int) – Radius of each node.

  • edge_size (int) – Line width of the edge.

Return type:

ndarray