title: Does exists a more efficient algortihm of finding the node(s) (in a graph) with the maximum degree?
body: <p><strong>Problem</strong>:</p>
  <p><em>Given a graph, find the node (s) with the maximum degree and return it/them in a list.</em></p>
  <p><strong>My solution:</strong></p>
  <pre><code>def max_degree(graph):
          &quot;&quot;&quot;
          :param graph: non-null and non-oriented networkx type graph to analyze.
          :return: list of nodes of this graph with maximum degree; 0 if the graph has no nodes; -1 if the graph is disconnected;
          &quot;&quot;&quot;
          if len(graph.nodes) == 0:
              return 0
          if not nx.is_connected(graph):
              return -1
          # node_grade_list -&gt; [(&lt;node&gt;, &lt;grade&gt;), ...]
          node_grade_list = sorted(grafo.degree, key=lambda x: x[1], reverse=True)
          max_grade = node_grade_list[0][1]
          max_grade_nodes_list = []
          for node in node_grade_list:
              if node[1] == max_grade:
                  max_grade_nodes_list.append(node[0])
          return max_grade_nodes_list
  </code></pre>
  <p><strong>Is there a way to make it much more efficient?</strong></p>