#include <bits/stdc++.h>
using namespace std;
int const mxn = 1e3 + 10;
long long inf = 1e9 + 10;
long long dis1[mxn], disn[mxn], dp1[mxn], dpn[mxn];
vector<long long> adj[mxn];
queue<int> q;
int n, m;
void bfs1() {
  fill(dis1, dis1 + mxn, inf);
  dis1[1] = 0;
  dp1[1] = 1;
  q.push(1);
  while (q.size()) {
    int v = q.front();
    q.pop();
    for (int u : adj[v]) {
      if (dis1[u] > dis1[v] + 1) {
        dis1[u] = dis1[v] + 1;
        dp1[u] = dp1[v];
        q.push(u);
      } else if (dis1[u] == dis1[v] + 1)
        dp1[u] += dp1[v];
    }
  }
}
void bfs2() {
  fill(disn, disn + mxn, inf);
  disn[n] = 0;
  dpn[n] = 1;
  q.push(n);
  while (q.size()) {
    int v = q.front();
    q.pop();
    for (int u : adj[v]) {
      if (disn[u] > disn[v] + 1) {
        disn[u] = disn[v] + 1;
        dpn[u] = dpn[v];
        q.push(u);
      } else if (disn[u] == disn[v] + 1)
        dpn[u] += dpn[v];
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int v, u;
    cin >> v >> u;
    adj[v].push_back(u);
    adj[u].push_back(v);
  }
  bfs1();
  bfs2();
  double kolhal = dpn[1];
  long long masa = disn[1];
  double ans = -1;
  for (int i = 2; i < n; i++) {
    if (disn[i] + dis1[i] == disn[1]) {
      ans = max(ans, double(2 * dp1[i] * dpn[i]));
    }
  }
  ans = max(ans, double(max(dp1[n], dpn[1])));
  cout << setprecision(20) << fixed << ans / kolhal;
}
