#include <bits/stdc++.h>
using namespace std;
void dijksra(const vector<vector<pair<int, int>>>& G, int s,
             vector<int>& dist) {
  int N = (int)G.size();
  vector<int> d(N, std::numeric_limits<int>::max());
  d[s] = 0;
  priority_queue<pair<int, int>, vector<pair<int, int>>,
                 greater<pair<int, int>>>
      Q;
  Q.push(pair<int, int>{0, s});
  while (!Q.empty()) {
    pair<int, int> p = Q.top();
    Q.pop();
    int v = p.second;
    if (d[v] < p.first) continue;
    for (const auto& i : G[v]) {
      if (d[i.first] > d[v] + i.second) {
        d[i.first] = d[v] + i.second;
        Q.push(pair<int, int>(d[i.first], i.first));
      }
    }
  }
  dist = move(d);
}
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<pair<int, int>>> G(N, vector<pair<int, int>>());
  bool ans = true;
  for (int i = 0; i < M; i++) {
    int L, R, D;
    cin >> L >> R >> D;
    L--;
    R--;
    vector<int> d(N, std::numeric_limits<int>::max());
    dijksra(G, L, d);
    if (d[R] == D || d[R] == std::numeric_limits<int>::max()) {
      G[L].emplace_back(R, D);
      G[R].emplace_back(L, D);
    } else {
      ans = false;
      break;
    }
  }
  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}
