#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long>> edge[1005];
priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,
               greater<pair<long long, long long>>>
    q;
long long dis[2][1005], num[2][1005], c[1005];
void dijkstra(long long s, long long t) {
  dis[t][s] = 0;
  q.push({0, s});
  num[t][s] = 1;
  while (!q.empty()) {
    long long x = q.top().first, u = q.top().second;
    q.pop();
    if (x > dis[t][u]) continue;
    for (auto v : edge[u]) {
      if (dis[t][v.second] == x + v.first) {
        num[t][v.second] += num[t][u];
      }
      if (dis[t][v.second] > x + v.first) {
        dis[t][v.second] = x + v.first;
        num[t][v.second] = num[t][u];
        q.push({dis[t][v.second], v.second});
      }
    }
  }
}
int main() {
  long long n, m;
  cin >> n >> m;
  memset(dis, 0x3f, sizeof(dis));
  for (long long i = 1; i <= m; i++) {
    long long u, v;
    cin >> u >> v;
    edge[u].push_back({1, v});
    edge[v].push_back({1, u});
  }
  dijkstra(1, 0);
  dijkstra(n, 1);
  for (long long i = 1; i <= n; i++) {
    if (dis[0][i] + dis[1][i] == dis[0][n]) {
      c[i] = 1;
    }
  }
  long long mx = 0;
  for (long long i = 1; i <= n; i++) {
    if (!c[i]) continue;
    long long sum = num[1][i] * num[0][i];
    if (i != 1 && i != n) sum *= 2;
    mx = max(mx, sum);
  }
  long double ans = (long double)mx / (long double)num[0][n];
  printf("%.15Lf\n", ans);
}
