#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 10;
vector<pair<long long, long long>> g[N];
bool used[N];
pair<long long, long long> kek[N];
long long cx;
vector<long long> pl, mn, sub;
void check(long long v) {
  sub.push_back(v);
  used[v] = true;
  if (kek[v].first == 1) {
    pl.push_back(kek[v].second);
  } else {
    mn.push_back(kek[v].second);
  }
  for (auto u : g[v]) {
    if (!used[u.first]) {
      kek[u.first] = {-kek[v].first, u.second - kek[v].second};
      check(u.first);
    } else {
      pair<long long, long long> other_val = {-kek[v].first,
                                              u.second - kek[v].second};
      if (other_val == kek[u.first]) {
        continue;
      }
      if (other_val.first == kek[u.first].first) {
        cerr << v << ' ' << u.first << ' ' << kek[u.first].second << ' '
             << other_val.second << '\n';
        cout << "NO\n";
        exit(0);
      }
      long long ncx = -(other_val.second - kek[u.first].second) /
                      (other_val.first - kek[u.first].first);
      if (cx != 1e18 && ncx != cx) {
        cout << "NO\n";
        exit(0);
      }
      cx = ncx;
    }
  }
}
long long vl[N];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    long long u, v, c;
    cin >> u >> v >> c;
    c *= 2;
    g[u].push_back({v, c});
    g[v].push_back({u, c});
  }
  for (long long v = 1; v <= n; v++) {
    if (!used[v]) {
      pl = {};
      mn = {};
      sub = {};
      cx = 1e18;
      kek[v] = {1, 0};
      check(v);
      if (cx != 1e18) {
        for (auto it : sub) {
          vl[it] = kek[it].first * cx + kek[it].second;
        }
        continue;
      }
      sort((pl).begin(), (pl).end());
      sort((mn).begin(), (mn).end());
      pair<long long, long long> best = {1e18, 1e18};
      vector<long long> pref_pl((long long)(pl).size()),
          suf_pl((long long)(pl).size());
      if (!pl.empty()) {
        pref_pl[0] = pl[0];
        for (long long i = 1; i < (long long)(pl).size(); i++) {
          pref_pl[i] = pref_pl[i - 1] + pl[i];
        }
        suf_pl.back() = pl.back();
        for (long long i = (long long)(pl).size() - 2; i >= 0; i--) {
          suf_pl[i] = suf_pl[i + 1] + pl[i];
        }
      }
      vector<long long> pref_mn((long long)(mn).size()),
          suf_mn((long long)(mn).size());
      if (!mn.empty()) {
        pref_mn[0] = mn[0];
        for (long long i = 1; i < (long long)(mn).size(); i++) {
          pref_mn[i] = pref_mn[i - 1] + mn[i];
        }
        suf_mn.back() = mn.back();
        for (long long i = (long long)(mn).size() - 2; i >= 0; i--) {
          suf_mn[i] = suf_mn[i + 1] + mn[i];
        }
      }
      for (long long i = 0; i < (long long)(pl).size(); i++) {
        long long cs = 0;
        if (i) {
          cs += pl[i] * i - pref_pl[i - 1];
        }
        if (i + 1 < (long long)(pl).size()) {
          cs += suf_pl[i + 1] - pl[i] * ((long long)(pl).size() - i - 1);
        }
        if (!mn.empty()) {
          long long ps =
              upper_bound((mn).begin(), (mn).end(), -pl[i]) - mn.begin();
          if (ps) {
            cs += ps * (-pl[i]) - pref_mn[ps - 1];
          }
          if (ps < (long long)(mn).size()) {
            cs += ((long long)(mn).size() - ps) * pl[i] + suf_mn[ps];
          }
        }
        best = min(best, make_pair(cs, -pl[i]));
      }
      for (long long i = 0; i < (long long)(mn).size(); i++) {
        long long cs = 0;
        if (i) {
          cs += mn[i] * i - pref_mn[i - 1];
        }
        if (i + 1 < (long long)(mn).size()) {
          cs += suf_mn[i + 1] - mn[i] * ((long long)(mn).size() - i - 1);
        }
        if (!pl.empty()) {
          long long ps =
              upper_bound((pl).begin(), (pl).end(), -mn[i]) - pl.begin();
          if (ps) {
            cs += ps * (-mn[i]) - pref_pl[ps - 1];
          }
          if (ps < (long long)(pl).size()) {
            cs += ((long long)(pl).size() - ps) * mn[i] + suf_pl[ps];
          }
        }
        best = min(best, make_pair(cs, mn[i]));
      }
      for (auto it : sub) {
        vl[it] = kek[it].first * best.second + kek[it].second;
      }
    }
  }
  cout << "YES\n";
  for (long long i = 1; i <= n; i++) {
    cout << fixed << setprecision(6) << (long double)vl[i] / 2.0 << ' ';
  }
  cout << '\n';
}
