#include <bits/stdc++.h>
using namespace std;
int val[100005], semn[100005], viz[100005];
double rasp[100005];
struct nr {
  int nod, w;
};
vector<nr> g[100005];
double x;
struct nr2 {
  int v, s;
};
int cmp(nr2 a, nr2 b) { return a.v < b.v; }
vector<nr2> aux;
void dfs(int nod) {
  aux.push_back({val[nod], semn[nod]});
  for (auto it : g[nod])
    if (viz[it.nod] == 0) {
      viz[it.nod] = 1;
      if (semn[nod] == -1) {
        semn[it.nod] = 1;
        val[it.nod] = it.w - val[nod];
      } else {
        semn[it.nod] = -1;
        val[it.nod] = it.w - val[nod];
      }
      dfs(it.nod);
    } else {
      int v, sem;
      if (semn[nod] == -1) {
        sem = 1;
        v = it.w - val[nod];
      } else {
        sem = -1;
        v = it.w - val[nod];
      }
      if (semn[it.nod] != sem)
        if (semn[it.nod] == -1)
          x = (double)(val[it.nod] - v) / 2;
        else
          x = (double)(v - val[it.nod]) / 2;
      else if (val[it.nod] != v) {
        printf("NO\n");
        exit(0);
      }
    }
}
void dfs2(int nod) {
  for (auto it : g[nod])
    if (viz[it.nod] == 1) {
      viz[it.nod] = 2;
      rasp[it.nod] = (double)val[it.nod] + (double)semn[it.nod] * x;
      dfs2(it.nod);
    }
}
int main() {
  int n, m, i, a, b, tip, ind, j;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= m; i++) {
    scanf("%d%d%d", &a, &b, &tip);
    g[a].push_back({b, tip});
    g[b].push_back({a, tip});
  }
  for (i = 1; i <= n; i++)
    if (viz[i] == 0) {
      viz[i] = 1;
      val[i] = 0;
      semn[i] = 1;
      x = 2e9;
      aux.clear();
      dfs(i);
      if (fabs(x - 2e9) > 1e-6) {
        viz[i] = 2;
        rasp[i] = x;
        dfs2(i);
      } else {
        double suma1 = 0, suma2 = 0;
        for (j = 0; j < aux.size(); j++)
          if (aux[j].s == 1) aux[j].v = -aux[j].v;
        sort(aux.begin(), aux.end(), cmp);
        x = aux[aux.size() / 2 - (1 - aux.size() % 2)].v;
        dfs2(i);
      }
    }
  for (i = 1; i <= n; i++)
    for (auto it : g[i])
      if (fabs(rasp[i] + rasp[it.nod] - (double)it.w) > 1e-6) {
        printf("NO\n");
        exit(0);
      }
  printf("YES\n");
  for (i = 1; i <= n; i++) printf("%.8lf ", rasp[i]);
  return 0;
}
