stanford-ppl / Green-Marl

A DSL for efficient Graph Analysis
Other
99 stars 36 forks source link

Reduction with -nan produces a result #102

Closed AustinBGibbons closed 12 years ago

AustinBGibbons commented 12 years ago

Hello, I wrote a small local cluster coefficient algorithm (#triangles / #possible triangles) and let some nodes not have any neighbors. (Pay no attention to my disregard for handling directed vs. undirected)

This produces [0.333333 -nan -nan -nan -nan ] total sum = -2147483648

Where the array are the LCC values (and are correct). I looked through the v0.4 spec for "undefined" and it does not seem to reference this scenario.

There are no warnings generated by the compiler, and I am not using +/- INF

Code (aside : I am bad at git, can you attach a file?)

Proc sum_of_nbrs_in_degree(G: Graph, LCC: N_P<Float>(G)) {
  Foreach (s: G.Nodes) {
    Int triangles = 0;
    Foreach (t:s.Nbrs) {
      Foreach (u:s.Nbrs) {
        If  (t.HasEdgeTo(u)) {triangles += 1;}
      }
    }
    Float deg = (Float) s.Degree();
    Float denom = deg * (deg-1);
    s.LCC = ((Float) triangles) / (denom);
  }

  Float ret = Sum(s: G.Nodes) {s.LCC};
  Return ret;
}
AustinBGibbons commented 12 years ago

Closed as being undefined behavior