496. Maximum Graph Power



The maximum power of a graph is determined by the highest power among all pairs of distinct vertices.
The power of two different vertices is defined as the total number of directly connected edges to either vertex. If an edge is directly connected to both vertices, it is only counted once.
Given a graph with n vertices and a set of edges connecting these vertices, represented by the array edges, find the maximum power of the graph.

Input Format

The first line of the input contains two integers n and m, representing the number of vertices and edges respectively. The following m lines contain two integers ai and bi, indicating a bidirectional edge between vertices ai and bi.

Output Format

Return an integer representing the maximum power of the graph.



4 4 0 1 0 3 1 2 1 3




  • 2 <= n <= 100
  • 0 <= edges.length <= n * (n - 1) / 2
  • edges[i].length == 2
  • 0 <= ai, bi <= n-1
  • ai != bi
  • Each pair of vertices has at most one edge connecting them.
  • Loading...

    View Submissions