Skip to main content

Graph.num_neighbours

Find the neighbours of a vertice

Usage

num_neighbours(vertex:int)

Parameters:
      vertex : int
            Source vertex

Returns:
      int
            The number of neighbours

Example

from jellybeans.structures import Graphg = Graph()g.add_vertex(1)g.add_vertex(5)g.add_vertex(9)g.add_bidirected_edge(1, 5, (20, 30))g.add_edge(5, 9, 12)print(g.num_neighbours(5)) # 2