org.apache.flink.graph.library.clustering.undirected.TriadicCensus.Result Java Examples
The following examples show how to use
org.apache.flink.graph.library.clustering.undirected.TriadicCensus.Result.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TriadicCensus.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Override public TriadicCensus<K, VV, EV> run(Graph<K, VV, EV> input) throws Exception { super.run(input); triangleCount = new Count<>(); DataSet<TriangleListing.Result<K>> triangles = input .run(new TriangleListing<K, VV, EV>() .setSortTriangleVertices(false) .setParallelism(parallelism)); triangleCount.run(triangles); vertexMetrics = new VertexMetrics<K, VV, EV>() .setParallelism(parallelism); input.run(vertexMetrics); return this; }
Example #2
Source File: TriadicCensus.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (obj == this) { return true; } if (obj.getClass() != getClass()) { return false; } Result rhs = (Result) obj; return new EqualsBuilder() .append(counts, rhs.counts) .isEquals(); }
Example #3
Source File: TriadicCensus.java From flink with Apache License 2.0 | 6 votes |
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (obj == this) { return true; } if (obj.getClass() != getClass()) { return false; } Result rhs = (Result) obj; return new EqualsBuilder() .append(counts, rhs.counts) .isEquals(); }
Example #4
Source File: TriadicCensus.java From flink with Apache License 2.0 | 6 votes |
@Override public TriadicCensus<K, VV, EV> run(Graph<K, VV, EV> input) throws Exception { super.run(input); triangleCount = new Count<>(); DataSet<TriangleListing.Result<K>> triangles = input .run(new TriangleListing<K, VV, EV>() .setSortTriangleVertices(false) .setParallelism(parallelism)); triangleCount.run(triangles); vertexMetrics = new VertexMetrics<K, VV, EV>() .setParallelism(parallelism); input.run(vertexMetrics); return this; }
Example #5
Source File: TriadicCensus.java From flink with Apache License 2.0 | 6 votes |
@Override public TriadicCensus<K, VV, EV> run(Graph<K, VV, EV> input) throws Exception { super.run(input); triangleCount = new Count<>(); DataSet<TriangleListing.Result<K>> triangles = input .run(new TriangleListing<K, VV, EV>() .setSortTriangleVertices(false) .setParallelism(parallelism)); triangleCount.run(triangles); vertexMetrics = new VertexMetrics<K, VV, EV>() .setParallelism(parallelism); input.run(vertexMetrics); return this; }
Example #6
Source File: TriadicCensus.java From flink with Apache License 2.0 | 6 votes |
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (obj == this) { return true; } if (obj.getClass() != getClass()) { return false; } Result rhs = (Result) obj; return new EqualsBuilder() .append(counts, rhs.counts) .isEquals(); }
Example #7
Source File: TriadicCensusTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testWithEmptyGraphWithoutVertices() throws Exception { Result expectedResult = new Result(0, 0, 0, 0); Result triadCensus = new TriadicCensus<LongValue, NullValue, NullValue>() .run(emptyGraphWithoutVertices) .execute(); assertEquals(expectedResult, triadCensus); }
Example #8
Source File: TriadicCensusTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testWithEmptyGraphWithVertices() throws Exception { Result expectedResult = new Result(0, 0, 0, 0); Result triadCensus = new TriadicCensus<LongValue, NullValue, NullValue>() .run(emptyGraphWithVertices) .execute(); assertEquals(expectedResult, triadCensus); }
Example #9
Source File: TriadicCensusTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testWithCompleteGraph() throws Exception { long expectedDegree = completeGraphVertexCount - 1; long expectedCount = completeGraphVertexCount * CombinatoricsUtils.binomialCoefficient((int) expectedDegree, 2) / 3; Result expectedResult = new Result(0, 0, 0, expectedCount); Result triadCensus = new TriadicCensus<LongValue, NullValue, NullValue>() .run(completeGraph) .execute(); assertEquals(expectedResult, triadCensus); }
Example #10
Source File: TriadicCensusTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testWithSimpleGraph() throws Exception { Result expectedResult = new Result(3, 8, 7, 2); Result triadCensus = new TriadicCensus<IntValue, NullValue, NullValue>() .run(undirectedSimpleGraph) .execute(); assertEquals(expectedResult, triadCensus); }
Example #11
Source File: TriadicCensus.java From flink with Apache License 2.0 | 5 votes |
public Result(long... counts) { Preconditions.checkArgument(counts.length == 4, "Expected 4 counts but received " + counts.length); this.counts = new BigInteger[counts.length]; for (int i = 0; i < counts.length; i++) { this.counts[i] = BigInteger.valueOf(counts[i]); } }
Example #12
Source File: TriadicCensusTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testWithEmptyGraphWithoutVertices() throws Exception { Result expectedResult = new Result(0, 0, 0, 0); Result triadCensus = new TriadicCensus<LongValue, NullValue, NullValue>() .run(emptyGraphWithoutVertices) .execute(); assertEquals(expectedResult, triadCensus); }
Example #13
Source File: TriadicCensusTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testWithEmptyGraphWithVertices() throws Exception { Result expectedResult = new Result(0, 0, 0, 0); Result triadCensus = new TriadicCensus<LongValue, NullValue, NullValue>() .run(emptyGraphWithVertices) .execute(); assertEquals(expectedResult, triadCensus); }
Example #14
Source File: TriadicCensusTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testWithCompleteGraph() throws Exception { long expectedDegree = completeGraphVertexCount - 1; long expectedCount = completeGraphVertexCount * CombinatoricsUtils.binomialCoefficient((int) expectedDegree, 2) / 3; Result expectedResult = new Result(0, 0, 0, expectedCount); Result triadCensus = new TriadicCensus<LongValue, NullValue, NullValue>() .run(completeGraph) .execute(); assertEquals(expectedResult, triadCensus); }
Example #15
Source File: TriadicCensusTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testWithSimpleGraph() throws Exception { Result expectedResult = new Result(3, 8, 7, 2); Result triadCensus = new TriadicCensus<IntValue, NullValue, NullValue>() .run(undirectedSimpleGraph) .execute(); assertEquals(expectedResult, triadCensus); }
Example #16
Source File: TriadicCensus.java From flink with Apache License 2.0 | 5 votes |
public Result(long... counts) { Preconditions.checkArgument(counts.length == 4, "Expected 4 counts but received " + counts.length); this.counts = new BigInteger[counts.length]; for (int i = 0; i < counts.length; i++) { this.counts[i] = BigInteger.valueOf(counts[i]); } }
Example #17
Source File: TriadicCensusTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testWithEmptyGraphWithoutVertices() throws Exception { Result expectedResult = new Result(0, 0, 0, 0); Result triadCensus = new TriadicCensus<LongValue, NullValue, NullValue>() .run(emptyGraphWithoutVertices) .execute(); assertEquals(expectedResult, triadCensus); }
Example #18
Source File: TriadicCensusTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testWithEmptyGraphWithVertices() throws Exception { Result expectedResult = new Result(0, 0, 0, 0); Result triadCensus = new TriadicCensus<LongValue, NullValue, NullValue>() .run(emptyGraphWithVertices) .execute(); assertEquals(expectedResult, triadCensus); }
Example #19
Source File: TriadicCensusTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testWithCompleteGraph() throws Exception { long expectedDegree = completeGraphVertexCount - 1; long expectedCount = completeGraphVertexCount * CombinatoricsUtils.binomialCoefficient((int) expectedDegree, 2) / 3; Result expectedResult = new Result(0, 0, 0, expectedCount); Result triadCensus = new TriadicCensus<LongValue, NullValue, NullValue>() .run(completeGraph) .execute(); assertEquals(expectedResult, triadCensus); }
Example #20
Source File: TriadicCensusTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testWithSimpleGraph() throws Exception { Result expectedResult = new Result(3, 8, 7, 2); Result triadCensus = new TriadicCensus<IntValue, NullValue, NullValue>() .run(undirectedSimpleGraph) .execute(); assertEquals(expectedResult, triadCensus); }
Example #21
Source File: TriadicCensus.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
public Result(long... counts) { Preconditions.checkArgument(counts.length == 4, "Expected 4 counts but received " + counts.length); this.counts = new BigInteger[counts.length]; for (int i = 0; i < counts.length; i++) { this.counts[i] = BigInteger.valueOf(counts[i]); } }
Example #22
Source File: TriadicCensus.java From flink with Apache License 2.0 | 4 votes |
public Result(BigInteger... counts) { Preconditions.checkArgument(counts.length == 4, "Expected 4 counts but received " + counts.length); this.counts = counts; }
Example #23
Source File: TriadicCensus.java From flink with Apache License 2.0 | 4 votes |
@Override public Result getResult() { // vertex metrics BigInteger bigVertexCount = BigInteger.valueOf(vertexMetrics.getResult().getNumberOfVertices()); BigInteger bigEdgeCount = BigInteger.valueOf(vertexMetrics.getResult().getNumberOfEdges()); BigInteger bigTripletCount = BigInteger.valueOf(vertexMetrics.getResult().getNumberOfTriplets()); // triangle count BigInteger bigTriangleCount = BigInteger.valueOf(triangleCount.getResult()); BigInteger one = BigInteger.ONE; BigInteger two = BigInteger.valueOf(2); BigInteger three = BigInteger.valueOf(3); BigInteger six = BigInteger.valueOf(6); // counts as ordered in TriadicCensus.Result BigInteger[] counts = new BigInteger[4]; // triads with three connecting edges = closed triplet = triangle counts[3] = bigTriangleCount; // triads with two connecting edges = open triplet; // deduct each triplet having been counted three times per triangle counts[2] = bigTripletCount.subtract(bigTriangleCount.multiply(three)); // triads with one connecting edge; each edge pairs with `vertex count - 2` vertices // then deduct twice for each open triplet and three times for each triangle counts[1] = bigEdgeCount .multiply(bigVertexCount.subtract(two)) .subtract(counts[2].multiply(two)) .subtract(counts[3].multiply(three)); // triads with zero connecting edges; // (vertex count choose 3) minus earlier counts counts[0] = bigVertexCount .multiply(bigVertexCount.subtract(one)) .multiply(bigVertexCount.subtract(two)) .divide(six) .subtract(counts[1]) .subtract(counts[2]) .subtract(counts[3]); return new Result(counts); }
Example #24
Source File: TriadicCensus.java From flink with Apache License 2.0 | 4 votes |
@Override public Result getResult() { // vertex metrics BigInteger bigVertexCount = BigInteger.valueOf(vertexMetrics.getResult().getNumberOfVertices()); BigInteger bigEdgeCount = BigInteger.valueOf(vertexMetrics.getResult().getNumberOfEdges()); BigInteger bigTripletCount = BigInteger.valueOf(vertexMetrics.getResult().getNumberOfTriplets()); // triangle count BigInteger bigTriangleCount = BigInteger.valueOf(triangleCount.getResult()); BigInteger one = BigInteger.ONE; BigInteger two = BigInteger.valueOf(2); BigInteger three = BigInteger.valueOf(3); BigInteger six = BigInteger.valueOf(6); // counts as ordered in TriadicCensus.Result BigInteger[] counts = new BigInteger[4]; // triads with three connecting edges = closed triplet = triangle counts[3] = bigTriangleCount; // triads with two connecting edges = open triplet; // deduct each triplet having been counted three times per triangle counts[2] = bigTripletCount.subtract(bigTriangleCount.multiply(three)); // triads with one connecting edge; each edge pairs with `vertex count - 2` vertices // then deduct twice for each open triplet and three times for each triangle counts[1] = bigEdgeCount .multiply(bigVertexCount.subtract(two)) .subtract(counts[2].multiply(two)) .subtract(counts[3].multiply(three)); // triads with zero connecting edges; // (vertex count choose 3) minus earlier counts counts[0] = bigVertexCount .multiply(bigVertexCount.subtract(one)) .multiply(bigVertexCount.subtract(two)) .divide(six) .subtract(counts[1]) .subtract(counts[2]) .subtract(counts[3]); return new Result(counts); }
Example #25
Source File: TriadicCensus.java From flink with Apache License 2.0 | 4 votes |
public Result(BigInteger... counts) { Preconditions.checkArgument(counts.length == 4, "Expected 4 counts but received " + counts.length); this.counts = counts; }
Example #26
Source File: TriadicCensus.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
public Result(BigInteger... counts) { Preconditions.checkArgument(counts.length == 4, "Expected 4 counts but received " + counts.length); this.counts = counts; }
Example #27
Source File: TriadicCensus.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Override public Result getResult() { // vertex metrics BigInteger bigVertexCount = BigInteger.valueOf(vertexMetrics.getResult().getNumberOfVertices()); BigInteger bigEdgeCount = BigInteger.valueOf(vertexMetrics.getResult().getNumberOfEdges()); BigInteger bigTripletCount = BigInteger.valueOf(vertexMetrics.getResult().getNumberOfTriplets()); // triangle count BigInteger bigTriangleCount = BigInteger.valueOf(triangleCount.getResult()); BigInteger one = BigInteger.ONE; BigInteger two = BigInteger.valueOf(2); BigInteger three = BigInteger.valueOf(3); BigInteger six = BigInteger.valueOf(6); // counts as ordered in TriadicCensus.Result BigInteger[] counts = new BigInteger[4]; // triads with three connecting edges = closed triplet = triangle counts[3] = bigTriangleCount; // triads with two connecting edges = open triplet; // deduct each triplet having been counted three times per triangle counts[2] = bigTripletCount.subtract(bigTriangleCount.multiply(three)); // triads with one connecting edge; each edge pairs with `vertex count - 2` vertices // then deduct twice for each open triplet and three times for each triangle counts[1] = bigEdgeCount .multiply(bigVertexCount.subtract(two)) .subtract(counts[2].multiply(two)) .subtract(counts[3].multiply(three)); // triads with zero connecting edges; // (vertex count choose 3) minus earlier counts counts[0] = bigVertexCount .multiply(bigVertexCount.subtract(one)) .multiply(bigVertexCount.subtract(two)) .divide(six) .subtract(counts[1]) .subtract(counts[2]) .subtract(counts[3]); return new Result(counts); }