@Override public void flatMap(Edge<T, Tuple3<ET, Degrees, Degrees>> edge, Collector<Tuple4<T, T, Degrees, LongValue>> out) throws Exception { Tuple3<ET, Degrees, Degrees> degrees = edge.f2; long sourceDegree = degrees.f1.getDegree().getValue(); long targetDegree = degrees.f2.getDegree().getValue(); boolean ordered = (sourceDegree < targetDegree || (sourceDegree == targetDegree && edge.f0.compareTo(edge.f1) < 0)); output.f0 = edge.f0; output.f1 = edge.f1; output.f2 = edge.f2.f1; output.f3 = ordered ? one : zero; out.collect(output); output.f0 = edge.f1; output.f1 = edge.f0; output.f2 = edge.f2.f2; output.f3 = ordered ? zero : one; out.collect(output); } }
@Override public void writeRecord(Vertex<T, Degrees> record) throws IOException { long degree = record.f1.getDegree().getValue(); long outDegree = record.f1.getOutDegree().getValue(); long inDegree = record.f1.getInDegree().getValue(); long bidirectionalEdges = outDegree + inDegree - degree; long triplets = degree * (degree - 1) / 2; vertexCount++; unidirectionalEdgeCount += degree - bidirectionalEdges; bidirectionalEdgeCount += bidirectionalEdges; tripletCount += triplets; maximumDegree = Math.max(maximumDegree, degree); maximumOutDegree = Math.max(maximumOutDegree, outDegree); maximumInDegree = Math.max(maximumInDegree, inDegree); maximumTriplets = Math.max(maximumTriplets, triplets); }
@Override public void reduce(Iterable<Tuple2<T, ByteValue>> values, Collector<Vertex<T, Degrees>> out) throws Exception { long degree = 0; long outDegree = 0; long inDegree = 0; for (Tuple2<T, ByteValue> edge : values) { output.f0 = edge.f0; byte bitmask = edge.f1.getValue(); degree++; if (bitmask == EdgeOrder.FORWARD.getBitmask()) { outDegree++; } else if (bitmask == EdgeOrder.REVERSE.getBitmask()) { inDegree++; } else { outDegree++; inDegree++; } } output.f1.getDegree().setValue(degree); output.f1.getOutDegree().setValue(outDegree); output.f1.getInDegree().setValue(inDegree); out.collect(output); } }
@Override public void reduce(Iterable<Tuple2<T, ByteValue>> values, Collector<Vertex<T, Degrees>> out) throws Exception { long degree = 0; long outDegree = 0; long inDegree = 0; for (Tuple2<T, ByteValue> edge : values) { output.f0 = edge.f0; byte bitmask = edge.f1.getValue(); degree++; if (bitmask == EdgeOrder.FORWARD.getBitmask()) { outDegree++; } else if (bitmask == EdgeOrder.REVERSE.getBitmask()) { inDegree++; } else { outDegree++; inDegree++; } } output.f1.getDegree().setValue(degree); output.f1.getOutDegree().setValue(outDegree); output.f1.getInDegree().setValue(inDegree); out.collect(output); } }
@Override public void reduce(Iterable<Tuple2<T, ByteValue>> values, Collector<Vertex<T, Degrees>> out) throws Exception { long degree = 0; long outDegree = 0; long inDegree = 0; for (Tuple2<T, ByteValue> edge : values) { output.f0 = edge.f0; byte bitmask = edge.f1.getValue(); degree++; if (bitmask == EdgeOrder.FORWARD.getBitmask()) { outDegree++; } else if (bitmask == EdgeOrder.REVERSE.getBitmask()) { inDegree++; } else { outDegree++; inDegree++; } } output.f1.getDegree().setValue(degree); output.f1.getOutDegree().setValue(outDegree); output.f1.getInDegree().setValue(inDegree); out.collect(output); } }
@Override public Tuple3<T, T, ByteValue> map(Edge<T, Tuple3<ET, Degrees, Degrees>> value) throws Exception { Tuple3<ET, Degrees, Degrees> degrees = value.f2; long sourceDegree = degrees.f1.getDegree().getValue(); long targetDegree = degrees.f2.getDegree().getValue(); if (sourceDegree < targetDegree || (sourceDegree == targetDegree && value.f0.compareTo(value.f1) < 0)) { output.f0 = value.f0; output.f1 = value.f1; output.f2 = forward; } else { output.f0 = value.f1; output.f1 = value.f0; output.f2 = reverse; } return output; } }
@Override public Tuple3<T, T, ByteValue> map(Edge<T, Tuple3<ET, Degrees, Degrees>> value) throws Exception { Tuple3<ET, Degrees, Degrees> degrees = value.f2; long sourceDegree = degrees.f1.getDegree().getValue(); long targetDegree = degrees.f2.getDegree().getValue(); if (sourceDegree < targetDegree || (sourceDegree == targetDegree && value.f0.compareTo(value.f1) < 0)) { output.f0 = value.f0; output.f1 = value.f1; output.f2 = forward; } else { output.f0 = value.f1; output.f1 = value.f0; output.f2 = reverse; } return output; } }
@Override public void flatMap(Edge<T, Tuple3<ET, Degrees, Degrees>> edge, Collector<Tuple4<T, T, Degrees, LongValue>> out) throws Exception { Tuple3<ET, Degrees, Degrees> degrees = edge.f2; long sourceDegree = degrees.f1.getDegree().getValue(); long targetDegree = degrees.f2.getDegree().getValue(); boolean ordered = (sourceDegree < targetDegree || (sourceDegree == targetDegree && edge.f0.compareTo(edge.f1) < 0)); output.f0 = edge.f0; output.f1 = edge.f1; output.f2 = edge.f2.f1; output.f3 = ordered ? one : zero; out.collect(output); output.f0 = edge.f1; output.f1 = edge.f0; output.f2 = edge.f2.f2; output.f3 = ordered ? zero : one; out.collect(output); } }
@Override public void flatMap(Edge<T, Tuple3<ET, Degrees, Degrees>> edge, Collector<Tuple4<T, T, Degrees, LongValue>> out) throws Exception { Tuple3<ET, Degrees, Degrees> degrees = edge.f2; long sourceDegree = degrees.f1.getDegree().getValue(); long targetDegree = degrees.f2.getDegree().getValue(); boolean ordered = (sourceDegree < targetDegree || (sourceDegree == targetDegree && edge.f0.compareTo(edge.f1) < 0)); output.f0 = edge.f0; output.f1 = edge.f1; output.f2 = edge.f2.f1; output.f3 = ordered ? one : zero; out.collect(output); output.f0 = edge.f1; output.f1 = edge.f0; output.f2 = edge.f2.f2; output.f3 = ordered ? zero : one; out.collect(output); } }
@Override public Tuple3<T, T, ByteValue> map(Edge<T, Tuple3<ET, Degrees, Degrees>> value) throws Exception { Tuple3<ET, Degrees, Degrees> degrees = value.f2; long sourceDegree = degrees.f1.getDegree().getValue(); long targetDegree = degrees.f2.getDegree().getValue(); if (sourceDegree < targetDegree || (sourceDegree == targetDegree && value.f0.compareTo(value.f1) < 0)) { output.f0 = value.f0; output.f1 = value.f1; output.f2 = forward; } else { output.f0 = value.f1; output.f1 = value.f0; output.f2 = reverse; } return output; } }
@Override public void flatMap(Edge<T, Tuple3<ET, Degrees, Degrees>> edge, Collector<Tuple4<T, T, Degrees, LongValue>> out) throws Exception { Tuple3<ET, Degrees, Degrees> degrees = edge.f2; long sourceDegree = degrees.f1.getDegree().getValue(); long targetDegree = degrees.f2.getDegree().getValue(); boolean ordered = (sourceDegree < targetDegree || (sourceDegree == targetDegree && edge.f0.compareTo(edge.f1) < 0)); output.f0 = edge.f0; output.f1 = edge.f1; output.f2 = edge.f2.f1; output.f3 = ordered ? one : zero; out.collect(output); output.f0 = edge.f1; output.f1 = edge.f0; output.f2 = edge.f2.f2; output.f3 = ordered ? zero : one; out.collect(output); } }
@Override public void writeRecord(Vertex<T, Degrees> record) throws IOException { long degree = record.f1.getDegree().getValue(); long outDegree = record.f1.getOutDegree().getValue(); long inDegree = record.f1.getInDegree().getValue(); long unidirectionalEdgesAsSource = degree - inDegree; long unidirectionalEdgesAsTarget = degree - outDegree; long bidirectionalEdges = inDegree + outDegree - degree; vertexCount++; unidirectionalEdgeCount += unidirectionalEdgesAsSource + unidirectionalEdgesAsTarget; bidirectionalEdgeCount += bidirectionalEdges; triplet021dCount += unidirectionalEdgesAsSource * (unidirectionalEdgesAsSource - 1) / 2; triplet021uCount += unidirectionalEdgesAsTarget * (unidirectionalEdgesAsTarget - 1) / 2; triplet021cCount += unidirectionalEdgesAsSource * unidirectionalEdgesAsTarget; triplet111dCount += unidirectionalEdgesAsTarget * bidirectionalEdges; triplet111uCount += unidirectionalEdgesAsSource * bidirectionalEdges; triplet201Count += bidirectionalEdges * (bidirectionalEdges - 1) / 2; }
@Override public void writeRecord(Vertex<T, Degrees> record) throws IOException { long degree = record.f1.getDegree().getValue(); long outDegree = record.f1.getOutDegree().getValue(); long inDegree = record.f1.getInDegree().getValue(); long unidirectionalEdgesAsSource = degree - inDegree; long unidirectionalEdgesAsTarget = degree - outDegree; long bidirectionalEdges = inDegree + outDegree - degree; vertexCount++; unidirectionalEdgeCount += unidirectionalEdgesAsSource + unidirectionalEdgesAsTarget; bidirectionalEdgeCount += bidirectionalEdges; triplet021dCount += unidirectionalEdgesAsSource * (unidirectionalEdgesAsSource - 1) / 2; triplet021uCount += unidirectionalEdgesAsTarget * (unidirectionalEdgesAsTarget - 1) / 2; triplet021cCount += unidirectionalEdgesAsSource * unidirectionalEdgesAsTarget; triplet111dCount += unidirectionalEdgesAsTarget * bidirectionalEdges; triplet111uCount += unidirectionalEdgesAsSource * bidirectionalEdges; triplet201Count += bidirectionalEdges * (bidirectionalEdges - 1) / 2; }
@Override public void writeRecord(Vertex<T, Degrees> record) throws IOException { long degree = record.f1.getDegree().getValue(); long outDegree = record.f1.getOutDegree().getValue(); long inDegree = record.f1.getInDegree().getValue(); long bidirectionalEdges = outDegree + inDegree - degree; long triplets = degree * (degree - 1) / 2; vertexCount++; unidirectionalEdgeCount += degree - bidirectionalEdges; bidirectionalEdgeCount += bidirectionalEdges; tripletCount += triplets; maximumDegree = Math.max(maximumDegree, degree); maximumOutDegree = Math.max(maximumOutDegree, outDegree); maximumInDegree = Math.max(maximumInDegree, inDegree); maximumTriplets = Math.max(maximumTriplets, triplets); }
@Override public void writeRecord(Vertex<T, Degrees> record) throws IOException { long degree = record.f1.getDegree().getValue(); long outDegree = record.f1.getOutDegree().getValue(); long inDegree = record.f1.getInDegree().getValue(); long bidirectionalEdges = outDegree + inDegree - degree; long triplets = degree * (degree - 1) / 2; vertexCount++; unidirectionalEdgeCount += degree - bidirectionalEdges; bidirectionalEdgeCount += bidirectionalEdges; tripletCount += triplets; maximumDegree = Math.max(maximumDegree, degree); maximumOutDegree = Math.max(maximumOutDegree, outDegree); maximumInDegree = Math.max(maximumInDegree, inDegree); maximumTriplets = Math.max(maximumTriplets, triplets); }
@Override public void writeRecord(Vertex<T, Degrees> record) throws IOException { long degree = record.f1.getDegree().getValue(); long outDegree = record.f1.getOutDegree().getValue(); long inDegree = record.f1.getInDegree().getValue(); long bidirectionalEdges = outDegree + inDegree - degree; long triplets = degree * (degree - 1) / 2; vertexCount++; unidirectionalEdgeCount += degree - bidirectionalEdges; bidirectionalEdgeCount += bidirectionalEdges; tripletCount += triplets; maximumDegree = Math.max(maximumDegree, degree); maximumOutDegree = Math.max(maximumOutDegree, outDegree); maximumInDegree = Math.max(maximumInDegree, inDegree); maximumTriplets = Math.max(maximumTriplets, triplets); }
@Override public void writeRecord(Vertex<T, Degrees> record) throws IOException { long degree = record.f1.getDegree().getValue(); long outDegree = record.f1.getOutDegree().getValue(); long inDegree = record.f1.getInDegree().getValue(); long unidirectionalEdgesAsSource = degree - inDegree; long unidirectionalEdgesAsTarget = degree - outDegree; long bidirectionalEdges = inDegree + outDegree - degree; vertexCount++; unidirectionalEdgeCount += unidirectionalEdgesAsSource + unidirectionalEdgesAsTarget; bidirectionalEdgeCount += bidirectionalEdges; triplet021dCount += unidirectionalEdgesAsSource * (unidirectionalEdgesAsSource - 1) / 2; triplet021uCount += unidirectionalEdgesAsTarget * (unidirectionalEdgesAsTarget - 1) / 2; triplet021cCount += unidirectionalEdgesAsSource * unidirectionalEdgesAsTarget; triplet111dCount += unidirectionalEdgesAsTarget * bidirectionalEdges; triplet111uCount += unidirectionalEdgesAsSource * bidirectionalEdges; triplet201Count += bidirectionalEdges * (bidirectionalEdges - 1) / 2; }
@Override public Vertex join(org.apache.flink.graph.Vertex<GradoopId, Degrees> degree, Vertex vertex) throws Exception { vertex.setProperty( vertexDegreesPropery, PropertyValue.create(degree.getValue().getDegree().getValue())); vertex.setProperty( vertexInDegreePropery, PropertyValue.create(degree.getValue().getInDegree().getValue())); vertex.setProperty( vertexOutDegreePropery, PropertyValue.create(degree.getValue().getOutDegree().getValue())); return vertex; } }
@Override public Vertex join(org.apache.flink.graph.Vertex<GradoopId, Degrees> degree, Vertex vertex) throws Exception { vertex.setProperty( vertexDegreesPropery, PropertyValue.create(degree.getValue().getDegree().getValue())); vertex.setProperty( vertexInDegreePropery, PropertyValue.create(degree.getValue().getInDegree().getValue())); vertex.setProperty( vertexOutDegreePropery, PropertyValue.create(degree.getValue().getOutDegree().getValue())); return vertex; } }
@Override public void writeRecord(Tuple3<T, Degrees, LongValue> record) throws IOException { Degrees degrees = record.f1; long degree = degrees.getDegree().getValue(); long lowDegree = record.f2.getValue(); long highDegree = degree - lowDegree; long triangleTriplets = lowDegree * (lowDegree - 1) / 2; long rectangleTriplets = triangleTriplets + lowDegree * highDegree; triangleTripletCount += triangleTriplets; rectangleTripletCount += rectangleTriplets; maximumTriangleTriplets = Math.max(maximumTriangleTriplets, triangleTriplets); maximumRectangleTriplets = Math.max(maximumRectangleTriplets, rectangleTriplets); }