#include <bits/stdc++.h>
using namespace std;
struct cv {
  long long c;
  long long val;
  cv(long long c_ = 0, long long val_ = 0) : c(c_), val(val_) {}
};
const long long MAXN = 100500;
vector<cv> res[MAXN];
vector<pair<long long, long long>> g[MAXN];
vector<long long> comp;
void dfs(long long v) {
  comp.push_back(v);
  for (auto p : g[v]) {
    long long u = p.first, sm = p.second;
    res[u].emplace_back(-res[v][0].c, sm - res[v][0].val);
    if ((long long)res[u].size() == 1) {
      dfs(u);
    }
  }
}
long double ans[MAXN];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout << fixed << setprecision(8);
  long long n, m;
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    long long u, v, c;
    cin >> u >> v >> c;
    g[u].emplace_back(v, c);
    g[v].emplace_back(u, c);
  }
  for (long long i = 1; i <= n; i++) {
    if (!res[i].empty()) {
      continue;
    }
    res[i].emplace_back(1, 0);
    comp = {};
    dfs(i);
    set<long long> psb;
    for (long long v : comp) {
      set<long long> cp, cm;
      for (cv p : res[v]) {
        if (p.c == 1) {
          cp.insert(p.val);
        } else {
          cm.insert(p.val);
        }
      }
      if ((long long)cp.size() > 1 || (long long)cm.size() > 1) {
        cout << "NO\n";
        return 0;
      }
      if (cp.empty() || cm.empty()) {
        continue;
      }
      long long val1 = *cp.begin(), val2 = *cm.begin();
      psb.insert(val2 - val1);
    }
    if ((long long)psb.size() > 1) {
      cout << "NO\n";
      return 0;
    }
    if ((long long)psb.size() == 1) {
      long double val = *psb.begin() / (long double)2;
      for (long long v : comp) {
        ans[v] = val * res[v][0].c + res[v][0].val;
      }
      continue;
    }
    const long double e = 1e-9;
    long double l = -1000, r = 1000;
    while (r - l > e) {
      long double val = (r - l) / 3;
      long double m1 = l + val;
      long double m2 = r - val;
      long double res1 = 0, res2 = 0;
      for (long long v : comp) {
        res1 += abs(res[v][0].c * m1 + res[v][0].val);
        res2 += abs(res[v][0].c * m2 + res[v][0].val);
      }
      if (res1 > res2) {
        l = m1;
      } else {
        r = m2;
      }
    }
    long double val = l;
    for (long long v : comp) {
      ans[v] = val * res[v][0].c + res[v][0].val;
    }
  }
  cout << "YES\n";
  for (long long v = 1; v <= n; v++) {
    cout << ans[v] << " ";
  }
  cout << '\n';
}
