public IDataTriangleInstance newInstance(int v) { IDataTriangleInstance instance = (IDataTriangleInstance)newInstance(); instance.V = v; return(instance); }
} // Isso é necessário no caso de IKey ser do tipo IVertex. #endregion #region Algorithm implementation public void startup_push() { IIteratorInstance <IKVPair <IVertex, IDataTriangle> > output_value_instance = (IIteratorInstance <IKVPair <IVertex, IDataTriangle> >)Output.Instance; IEnumerator <int> V = g.vertexSet().GetEnumerator(); while (V.MoveNext()) { int v = V.Current; if (!isGhost(v)) { ICollection <int> vneighbors = g.neighborsOf(v); foreach (int w in vneighbors) { if (v < w) //buscam-se os vérices maiores { if (isGhost(w)) { IKVPairInstance <IVertex, IDataTriangle> item = (IKVPairInstance <IVertex, IDataTriangle>)Output.createItem(); IVertexInstance ok = (IVertexInstance)item.Key; IDataTriangleInstance ov = (IDataTriangleInstance)item.Value; ok.Id = w; ov.V = v; output_value_instance.put(item); } else { IList <KeyValuePair <int, int> > l; if (!triangles.TryGetValue(v, out l)) { l = new List <KeyValuePair <int, int> > (); triangles[v] = l; } IEnumerator <int> wneighbors = g.iteratorNeighborsOf(w); while (wneighbors.MoveNext()) { int z = wneighbors.Current; if (w < z && vneighbors.Contains(z)) { l.Add(new KeyValuePair <int, int> (w, z)); count++; } } } } } } } }
public void pull() { IKVPairInstance <IVertex, IIterator <IDataTriangle> > input_values_instance = (IKVPairInstance <IVertex, IIterator <IDataTriangle> >)Input_values.Instance; IVertexInstance ikey = (IVertexInstance)input_values_instance.Key; IIteratorInstance <IDataTriangle> ivalues = (IIteratorInstance <IDataTriangle>)input_values_instance.Value; IIteratorInstance <IKVPair <IVertex, IDataTriangle> > output_value = (IIteratorInstance <IKVPair <IVertex, IDataTriangle> >)Output.Instance; object o; int w = ikey.Id; while (ivalues.fetch_next(out o)) { int v = ((IDataTriangleInstance)o).V; int z = ((IDataTriangleInstance)o).W; IEnumerator <int> wneighbors = g.iteratorNeighborsOf(w); while (wneighbors.MoveNext()) { int zw = wneighbors.Current; if (w < zw) { if (z == 0) { IKVPairInstance <IVertex, IDataTriangle> item = (IKVPairInstance <IVertex, IDataTriangle>)Output.createItem(); IVertexInstance ok = (IVertexInstance)item.Key; IDataTriangleInstance ov = (IDataTriangleInstance)item.Value; ok.Id = v; ov.V = w; ov.W = zw; output_value.put(item); } else { IList <KeyValuePair <int, int> > l; if (!triangles.TryGetValue(w, out l)) { l = new List <KeyValuePair <int, int> > (); triangles [w] = l; } if (z == zw) { l.Add(new KeyValuePair <int, int>(v, zw)); count++; } } } } } }
public void gust0() { IIteratorInstance <IKVPair <IVertex, IDataTriangle> > output_value_instance = (IIteratorInstance <IKVPair <IVertex, IDataTriangle> >)Output.Instance; ConcurrentDictionary <int, IList <KeyValuePair <int, int> > > buffer_tmp = new ConcurrentDictionary <int, IList <KeyValuePair <int, int> > >(); IEnumerator <int> next = messages.Keys.GetEnumerator(); while (next.MoveNext()) { int w = next.Current; IList <KeyValuePair <int, int> > l; messages.TryRemove(w, out l); IEnumerator <int> wneighbors = g.iteratorNeighborsOf(w); while (wneighbors.MoveNext()) { int z = wneighbors.Current; if (w < z) { foreach (KeyValuePair <int, int> kvw in l) { int v = kvw.Key; if (isGhost(v)) { IKVPairInstance <IVertex, IDataTriangle> item = (IKVPairInstance <IVertex, IDataTriangle>)Output.createItem(); IVertexInstance ok = (IVertexInstance)item.Key; IDataTriangleInstance ov = (IDataTriangleInstance)item.Value; ok.Id = v; ov.V = z; ov.W = w; output_value_instance.put(item); } else { IList <KeyValuePair <int, int> > lz; if (!buffer_tmp.TryGetValue(v, out lz)) { lz = new List <KeyValuePair <int, int> > (); buffer_tmp[v] = lz; } lz.Add(new KeyValuePair <int, int>(z, w)); } } } } } messages = buffer_tmp; }
public void startup_push() { IIteratorInstance <IKVPair <IVertex, IDataTriangle> > output_value_instance = (IIteratorInstance <IKVPair <IVertex, IDataTriangle> >)Output.Instance; int v, ordered, i, j; IEnumerator <int> V = g.vertexSet().GetEnumerator(); while (V.MoveNext()) { v = V.Current; if (!isGhost(v)) { IEnumerator <int> vneighbors = g.iteratorNeighborsOf(v); while (vneighbors.MoveNext()) { int bigger = vneighbors.Current; if (v < bigger) //buscam-se os vérices maiores { if (isGhost(bigger)) { IKVPairInstance <IVertex, IDataTriangle> item = (IKVPairInstance <IVertex, IDataTriangle>)Output.createItem(); IVertexInstance ok = (IVertexInstance)item.Key; IDataTriangleInstance ov = (IDataTriangleInstance)item.Value; ok.Id = bigger; ov.V = v; output_value_instance.put(item); } else { IList <KeyValuePair <int, int> > l; if (!messages.TryGetValue(bigger, out l)) { l = new List <KeyValuePair <int, int> > (); messages[bigger] = l; } l.Add(new KeyValuePair <int, int>(v, 0)); } } } } } }