#include <bits/stdc++.h>
using namespace std;
const long long N = 1005, M = 100005, inf = 1e18;
long long n, m;
long long pnt[M], nxt[M], head[N], du[N], E = -1;
long long dis1[N], cnt1[N], dis2[N], cnt2[N], vis[N];
void add(long long u, long long v) {
  E++;
  pnt[E] = v;
  nxt[E] = head[u];
  head[u] = E;
  du[u]++;
}
queue<pair<long long, pair<long long, long long> > > Q;
pair<long long, pair<long long, long long> > mkp(long long a, long long b,
                                                 long long c) {
  pair<long long, pair<long long, long long> > tmp;
  tmp.first = a;
  tmp.second.first = b;
  tmp.second.second = c;
  return tmp;
}
int main() {
  scanf("%lld%lld", &n, &m);
  memset(head, -1, sizeof(head));
  for (long long i = 1; i <= m; i++) {
    long long a, b;
    scanf("%lld%lld", &a, &b);
    add(a, b);
    add(b, a);
  }
  for (long long i = 1; i <= n; i++) dis1[i] = dis2[i] = inf;
  memset(cnt1, 0, sizeof(cnt1));
  memset(cnt2, 0, sizeof(cnt2));
  memset(vis, 0, sizeof(vis));
  dis1[1] = 0;
  cnt1[1] = 1;
  Q.push(mkp(1, 0, -1));
  long long dist = -1;
  while (!Q.empty()) {
    long long x = Q.front().first, step = Q.front().second.first,
              fa = Q.front().second.second;
    Q.pop();
    if (x == n) {
      if (dist == -1)
        dist = step;
      else if (step > dist)
        break;
    }
    for (long long i = head[x]; i != -1; i = nxt[i]) {
      if (pnt[i] != fa) {
        if (dis1[pnt[i]] > step + 1) {
          dis1[pnt[i]] = step + 1;
          cnt1[pnt[i]] = cnt1[x];
          vis[i] = vis[i ^ 1] = 1;
          Q.push(mkp(pnt[i], step + 1, x));
        } else if (dis1[pnt[i]] == step + 1) {
          vis[i] = vis[i ^ 1] = 1;
          cnt1[pnt[i]] += cnt1[x];
        }
      }
    }
  }
  while (!Q.empty()) Q.pop();
  memset(vis, 0, sizeof(vis));
  memset(cnt2, 0, sizeof(cnt2));
  cnt2[n] = 1;
  Q.push(mkp(n, 0, -1));
  while (!Q.empty()) {
    long long x = Q.front().first, fa = Q.front().second.second;
    Q.pop();
    for (int i = head[x]; i != -1; i = nxt[i]) {
      if (dis1[pnt[i]] == dis1[x] - 1) {
        cnt2[pnt[i]] += cnt2[x];
        if (vis[pnt[i]] == 0) {
          vis[pnt[i]] = 1;
          Q.push(mkp(pnt[i], 0, x));
        }
      }
    }
  }
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    if (i == 1 || i == n)
      ans = max(ans, cnt1[i] * cnt2[i]);
    else
      ans = max(ans, 2 * cnt1[i] * cnt2[i]);
  }
  printf("%.16lf\n", (double)ans / cnt1[n]);
  return 0;
}
