#include <bits/stdc++.h>
using namespace std;
struct edge {
  int x, c;
  edge(int nx = 0, int nc = 0) {
    x = nx;
    c = nc;
  }
};
int n, m, x, y, c, tot = 0, ty[100005], num[100005], vis[100005];
double a[100005], nw;
int res[100005];
vector<int> al;
vector<edge> s[100005];
const double eps = 1e-9;
void dfs(int p) {
  al.push_back(p);
  vis[p] = 1;
  edge v;
  int nty, nnum;
  double nnw;
  for (int i = 0; i < s[p].size(); i++) {
    v = s[p][i];
    nty = -ty[p];
    nnum = ((v.c == 1) ? 1 : 2) - num[p];
    if (vis[v.x] == 1) {
      if (nty == ty[v.x]) {
        if (nnum != num[v.x]) {
          printf("NO\n");
          exit(0);
        } else
          continue;
      } else {
        nnw = ((double)(num[v.x] - nnum)) / (double)(nty - ty[v.x]);
        if (nw < -100000000.0)
          nw = nnw;
        else {
          if (fabs(nw - nnw) < eps) continue;
          printf("NO\n");
          exit(0);
        }
      }
      continue;
    }
    ty[v.x] = nty;
    num[v.x] = nnum;
    res[++tot] = -num[v.x] / ty[v.x];
    dfs(v.x);
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &x, &y, &c);
    s[x].push_back(edge(y, c));
    s[y].push_back(edge(x, c));
  }
  for (int i = 1; i <= n; i++) {
    if (vis[i]) continue;
    al.clear();
    tot = 0;
    nw = -1000000000.0;
    ty[i] = 1;
    num[i] = 0;
    res[++tot] = 0;
    dfs(i);
    sort(res + 1, res + tot + 1);
    if (nw < -100000000.0) nw = (double)res[(tot + 1) / 2];
    for (int j = 0; j < al.size(); j++)
      a[al[j]] = (double)num[al[j]] + (double)ty[al[j]] * nw;
  }
  printf("YES\n");
  for (int i = 1; i <= n; i++) printf("%.1f ", a[i]);
  return 0;
}
