@Override public int hashCode() { if (hasher == null) { hasher = new MurmurHash(HASH_SEED); } return hasher.reset() .hash(getVertexId0().hashCode()) .hash(degree.getValue()) .hash(triangleCount.getValue()) .hash(); } }
/** * Get the local clustering coefficient score. This is computed as the * number of edges between neighbors, equal to the triangle count, * divided by the number of potential edges between neighbors. * * <p>A score of {@code Double.NaN} is returned for a vertex with degree 1 * for which both the triangle count and number of neighbors are zero. * * @return local clustering coefficient score */ public double getLocalClusteringCoefficientScore() { long degree = getDegree().getValue(); long neighborPairs = degree * (degree - 1) / 2; return (neighborPairs == 0) ? Double.NaN : getTriangleCount().getValue() / (double) neighborPairs; }
/** * Get the local clustering coefficient score. This is computed as the * number of edges between neighbors, equal to the triangle count, * divided by the number of potential edges between neighbors. * * <p>A score of {@code Double.NaN} is returned for a vertex with degree 1 * for which both the triangle count and number of neighbors are zero. * * @return local clustering coefficient score */ public double getLocalClusteringCoefficientScore() { long degree = getDegree().getValue(); long neighborPairs = degree * (degree - 1) / 2; return (neighborPairs == 0) ? Double.NaN : getTriangleCount().getValue() / (double) neighborPairs; }
/** * Get the local clustering coefficient score. This is computed as the * number of edges between neighbors, equal to the triangle count, * divided by the number of potential edges between neighbors. * * A score of {@code Double.NaN} is returned for a vertex with degree 1 * for which both the triangle count and number of neighbors are zero. * * @return local clustering coefficient score */ public double getLocalClusteringCoefficientScore() { long degree = getDegree().getValue(); long neighborPairs = degree * (degree - 1) / 2; return (neighborPairs == 0) ? Double.NaN : getTriangleCount().getValue() / (double)neighborPairs; }
@Override public String toString() { return "(" + getVertexId0() + "," + degree + "," + triangleCount + ")"; }
@Override public String toString() { return "(" + getVertexId0() + "," + degree + "," + triangleCount + ")"; }
@Override public void writeRecord(LocalClusteringCoefficient.Result<T> record) throws IOException { vertexCount++; // local clustering coefficient is only defined on vertices with // at least two neighbors yielding at least one pair of neighbors if (record.getDegree().getValue() > 1) { sumOfLocalClusteringCoefficient += record.getLocalClusteringCoefficientScore(); } }
@Override public void writeRecord(LocalClusteringCoefficient.Result<T> record) throws IOException { vertexCount++; // local clustering coefficient is only defined on vertices with // at least two neighbors yielding at least one pair of neighbors if (record.getDegree().getValue() > 1) { sumOfLocalClusteringCoefficient += record.getLocalClusteringCoefficientScore(); } }
@Override public Result<T> join(Vertex<T, LongValue> vertexAndDegree, Tuple2<T, LongValue> vertexAndTriangleCount) throws Exception { output.setVertexId0(vertexAndDegree.f0); output.setDegree(vertexAndDegree.f1); output.setTriangleCount((vertexAndTriangleCount == null) ? zero : vertexAndTriangleCount.f1); return output; } }
@Override public Result<T> join(Vertex<T, LongValue> vertexAndDegree, Tuple2<T, LongValue> vertexAndTriangleCount) throws Exception { output.setVertexId0(vertexAndDegree.f0); output.setDegree(vertexAndDegree.f1); output.setTriangleCount((vertexAndTriangleCount == null) ? zero : vertexAndTriangleCount.f1); return output; } }
@Override public int hashCode() { if (hasher == null) { hasher = new MurmurHash(HASH_SEED); } return hasher.reset() .hash(getVertexId0().hashCode()) .hash(degree.getValue()) .hash(triangleCount.getValue()) .hash(); } }
/** * Format values into a human-readable string. * * @return verbose string */ public String toPrintableString() { return "Vertex ID: " + getVertexId0() + ", vertex degree: " + getDegree() + ", triangle count: " + getTriangleCount() + ", local clustering coefficient: " + getLocalClusteringCoefficientScore(); }
@Override public int hashCode() { if (hasher == null) { hasher = new MurmurHash(HASH_SEED); } return hasher.reset() .hash(getVertexId0().hashCode()) .hash(degree.getValue()) .hash(triangleCount.getValue()) .hash(); } }
@Override public Tuple2<GradoopId, Double> map( LocalClusteringCoefficient.Result<GradoopId> result) throws Exception { double value = result.getLocalClusteringCoefficientScore(); if (Double.isNaN(value)) { value = 0.0; } return Tuple2.of(result.getVertexId0(), value); } }
/** * Format values into a human-readable string. * * @return verbose string */ @Override public String toPrintableString() { return "Vertex ID: " + getVertexId0() + ", vertex degree: " + degree + ", triangle count: " + triangleCount + ", local clustering coefficient: " + getLocalClusteringCoefficientScore(); }
/** * Format values into a human-readable string. * * @return verbose string */ @Override public String toPrintableString() { return "Vertex ID: " + getVertexId0() + ", vertex degree: " + degree + ", triangle count: " + triangleCount + ", local clustering coefficient: " + getLocalClusteringCoefficientScore(); }
@Override public Tuple2<GradoopId, Double> map( LocalClusteringCoefficient.Result<GradoopId> result) throws Exception { double value = result.getLocalClusteringCoefficientScore(); if (Double.isNaN(value)) { value = 0.0; } return Tuple2.of(result.getVertexId0(), value); } }
@Override public void writeRecord(LocalClusteringCoefficient.Result<T> record) throws IOException { vertexCount++; // local clustering coefficient is only defined on vertices with // at least two neighbors yielding at least one pair of neighbors if (record.getDegree().getValue() > 1) { sumOfLocalClusteringCoefficient += record.getLocalClusteringCoefficientScore(); } }
/** * Get the local clustering coefficient score. This is computed as the * number of edges between neighbors, equal to the triangle count, * divided by the number of potential edges between neighbors. * * <p>A score of {@code Double.NaN} is returned for a vertex with degree 1 * for which both the triangle count and number of neighbors are zero. * * @return local clustering coefficient score */ public double getLocalClusteringCoefficientScore() { long degree = getDegree().getValue(); long neighborPairs = degree * (degree - 1) / 2; return (neighborPairs == 0) ? Double.NaN : getTriangleCount().getValue() / (double) neighborPairs; }
/** * Format values into a human-readable string. * * @return verbose string */ @Override public String toPrintableString() { return "Vertex ID: " + getVertexId0() + ", vertex degree: " + degree + ", triangle count: " + triangleCount + ", local clustering coefficient: " + getLocalClusteringCoefficientScore(); }