#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<vector<int>> adj;
vector<int> vis1, vis2;
vector<long double> dp1, dp2;
int main() {
  cin >> n >> m;
  adj.assign(n, vector<int>());
  dp1.assign(n, 0);
  dp2.assign(n, 0);
  vis1.assign(n, -1);
  vis2.assign(n, -1);
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  queue<pair<int, pair<int, int>>> q;
  q.push({0, {0, -1}});
  while (!q.empty()) {
    pair<int, pair<int, int>> cur = q.front();
    q.pop();
    int i = cur.first;
    long double x = 1;
    bool chk = false;
    if (vis1[i] == -1) chk = true;
    if (cur.second.second != -1) x = dp1[cur.second.second];
    if (vis1[i] == cur.second.first || vis1[i] == -1) {
      dp1[i] += x;
      vis1[i] = cur.second.first;
    }
    if (chk && i != n - 1)
      for (auto it : adj[i]) {
        if (vis1[it] == -1 || vis1[it] == vis1[i] + 1) {
          q.push({it, {vis1[i] + 1, i}});
        }
      }
  }
  q.push({n - 1, {0, -1}});
  while (!q.empty()) {
    pair<int, pair<int, int>> cur = q.front();
    q.pop();
    int i = cur.first;
    long double x = 1;
    bool chk = false;
    if (vis2[i] == -1) chk = true;
    if (cur.second.second != -1) x = dp2[cur.second.second];
    if (vis2[i] == cur.second.first || vis2[i] == -1) {
      dp2[i] += x;
      vis2[i] = cur.second.first;
    }
    if (chk && i != 0)
      for (auto it : adj[i]) {
        if (vis2[it] == -1 || vis2[it] == vis2[i] + 1) {
          q.push({it, {cur.second.first + 1, i}});
        }
      }
  }
  long double res = 0.5;
  for (int i = 1; i < n - 1; ++i) {
    if (vis1[i] + vis2[i] == vis2[0] + vis1[0])
      res = max(res, (long double)((1.0 * dp1[i] * dp2[i]) / dp1[n - 1]));
  }
  res *= 2;
  cout << setprecision(10) << fixed;
  cout << res;
  return 0;
}
