#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:64777216")
using namespace std;
const int INF = ~(1 << 31);
const double EPS = 1e-6;
const double PI = 3.141592653589793;
vector<vector<int> > g;
vector<long long> dp, dd;
vector<long long> da, db;
int n, m;
vector<long long> bfs(int v) {
  queue<int> q;
  vector<long long> d(n, 0);
  vector<bool> u(n, 0);
  u[v] = 1;
  q.push(v);
  while (!q.empty()) {
    v = q.front();
    q.pop();
    for (int i = 0; i < g[v].size(); i++) {
      int to = g[v][i];
      if (!u[to]) {
        u[to] = 1;
        q.push(to);
        d[to] = d[v] + 1;
      }
    }
  }
  return d;
}
long long go(int v) {
  if (dp[v] > 0) return dp[v];
  if (v == 0) return 1;
  for (int i = 0; i < n; i++) {
    if (da[i] == da[v] - 1) {
      for (int j = 0; j < g[i].size(); j++) {
        if (g[i][j] == v) {
          dp[v] += go(i);
          break;
        }
      }
    }
  }
  return dp[v];
}
long long go2(int v) {
  if (dd[v] > 0) return dd[v];
  if (v == n - 1) return 1;
  for (int i = 0; i < n; i++) {
    if (db[i] == db[v] - 1) {
      for (int j = 0; j < g[i].size(); j++) {
        if (g[i][j] == v) {
          dd[v] += go2(i);
          break;
        }
      }
    }
  }
  return dd[v];
}
int main() {
  int a, b;
  cin >> n >> m;
  g.assign(n, vector<int>());
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    g[a - 1].push_back(b - 1);
    g[b - 1].push_back(a - 1);
  }
  da = bfs(0);
  db = bfs(n - 1);
  dp.assign(n, 0);
  dd.assign(n, 0);
  go(n - 1);
  go2(0);
  long long mr = -1;
  for (int i = 0; i < n - 1; i++) mr = max(mr, dp[i] * dd[i]);
  mr *= 2;
  mr = max(mr, dp[n - 1]);
  if (n == 2)
    printf("1\n");
  else
    printf("%.10lf\n", (double)mr / (dp[n - 1] + 0.0));
  return 0;
}
