org.apache.flink.types.NullValue Java Examples

The following examples show how to use org.apache.flink.types.NullValue. 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: VertexOutDegreeTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithDirectedSimpleGraph() throws Exception {
	DataSet<Vertex<IntValue, LongValue>> outDegree = directedSimpleGraph
		.run(new VertexOutDegree<IntValue, NullValue, NullValue>()
			.setIncludeZeroDegreeVertices(true));

	String expectedResult =
		"(0,2)\n" +
		"(1,0)\n" +
		"(2,2)\n" +
		"(3,2)\n" +
		"(4,0)\n" +
		"(5,1)";

	TestBaseUtils.compareResultAsText(outDegree.collect(), expectedResult);
}
 
Example #2
Source File: VertexDegreeTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithEmptyGraphWithVertices() throws Exception {
	DataSet<Vertex<LongValue, LongValue>> degree;

	degree = emptyGraphWithVertices
		.run(new VertexDegree<LongValue, NullValue, NullValue>()
			.setIncludeZeroDegreeVertices(false));

	assertEquals(0, degree.collect().size());

	degree = emptyGraphWithVertices
		.run(new VertexDegree<LongValue, NullValue, NullValue>()
			.setIncludeZeroDegreeVertices(true));

	String expectedResult =
		"(0,0)\n" +
		"(1,0)\n" +
		"(2,0)";

	TestBaseUtils.compareResultAsText(degree.collect(), expectedResult);
}
 
Example #3
Source File: JaccardIndexTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithSimpleGraphWithMaximumScore() throws Exception {
	DataSet<Result<IntValue>> ji = undirectedSimpleGraph
		.run(new JaccardIndex<IntValue, NullValue, NullValue>()
			.setMaximumScore(1, 2));

	String expectedResult =
		"(0,1,1,4)\n" +
		"(0,2,1,4)\n" +
		"(0,3,2,4)\n" +
		"(1,2,2,4)\n" +
		"(1,3,1,6)\n" +
		"(1,4,1,3)\n" +
		"(1,5,1,3)\n" +
		"(2,3,1,6)\n" +
		"(2,4,1,3)\n" +
		"(2,5,1,3)\n";

	TestBaseUtils.compareResultAsText(ji.collect(), expectedResult);
}
 
Example #4
Source File: VertexDegreeTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithEmptyGraphWithoutVertices() throws Exception {
	DataSet<Vertex<LongValue, LongValue>> degree;

	degree = emptyGraphWithoutVertices
		.run(new VertexDegree<LongValue, NullValue, NullValue>()
			.setIncludeZeroDegreeVertices(false));

	assertEquals(0, degree.collect().size());

	degree = emptyGraphWithoutVertices
		.run(new VertexDegree<LongValue, NullValue, NullValue>()
			.setIncludeZeroDegreeVertices(true));

	assertEquals(0, degree.collect().size());
}
 
Example #5
Source File: EdgeDegreesPairTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithSimpleGraph() throws Exception {
	String expectedResult =
		"(0,1,((null),(2,2,0),(3,0,3)))\n" +
		"(0,2,((null),(2,2,0),(3,2,1)))\n" +
		"(2,1,((null),(3,2,1),(3,0,3)))\n" +
		"(2,3,((null),(3,2,1),(4,2,2)))\n" +
		"(3,1,((null),(4,2,2),(3,0,3)))\n" +
		"(3,4,((null),(4,2,2),(1,0,1)))\n" +
		"(5,3,((null),(1,1,0),(4,2,2)))";

	DataSet<Edge<IntValue, Tuple3<NullValue, Degrees, Degrees>>> degreesPair = directedSimpleGraph
		.run(new EdgeDegreesPair<>());

	TestBaseUtils.compareResultAsText(degreesPair.collect(), expectedResult);
}
 
Example #6
Source File: VertexInDegreeTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithDirectedSimpleGraph() throws Exception {
	DataSet<Vertex<IntValue, LongValue>> inDegree = directedSimpleGraph
		.run(new VertexInDegree<IntValue, NullValue, NullValue>()
			.setIncludeZeroDegreeVertices(true));

	String expectedResult =
		"(0,0)\n" +
		"(1,3)\n" +
		"(2,1)\n" +
		"(3,2)\n" +
		"(4,1)\n" +
		"(5,0)";

	TestBaseUtils.compareResultAsText(inDegree.collect(), expectedResult);
}
 
Example #7
Source File: ConnectedComponentsWithRandomisedEdgesITCase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
protected void testProgram() throws Exception {
	ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	DataSet<Long> vertexIds = env.generateSequence(1, NUM_VERTICES);
	DataSet<String> edgeString = env.fromElements(ConnectedComponentsData.getRandomOddEvenEdges(NUM_EDGES, NUM_VERTICES, SEED).split("\n"));

	DataSet<Edge<Long, NullValue>> edges = edgeString.map(new EdgeParser());

	DataSet<Vertex<Long, Long>> initialVertices = vertexIds.map(new IdAssigner());

	Graph<Long, Long, NullValue> graph = Graph.fromDataSet(initialVertices, edges, env);

	DataSet<Vertex<Long, Long>> result = graph.run(new ConnectedComponents<>(100));

	result.writeAsCsv(resultPath, "\n", " ");
	env.execute();
}
 
Example #8
Source File: VertexInDegreeTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithUndirectedSimpleGraph() throws Exception {
	DataSet<Vertex<IntValue, LongValue>> inDegree = undirectedSimpleGraph
		.run(new VertexInDegree<IntValue, NullValue, NullValue>()
			.setIncludeZeroDegreeVertices(true));

	String expectedResult =
		"(0,2)\n" +
		"(1,3)\n" +
		"(2,3)\n" +
		"(3,4)\n" +
		"(4,1)\n" +
		"(5,1)";

	TestBaseUtils.compareResultAsText(inDegree.collect(), expectedResult);
}
 
Example #9
Source File: GSAConnectedComponents.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
public DataSet<Vertex<K, VV>> run(Graph<K, VV, EV> graph) throws Exception {

	// get type information for vertex value
	TypeInformation<VV> valueTypeInfo = ((TupleTypeInfo<?>) graph.getVertices().getType()).getTypeAt(1);

	Graph<K, VV, NullValue> undirectedGraph = graph
		.mapEdges(new MapTo<>(NullValue.getInstance()))
		.getUndirected();

	return undirectedGraph.runGatherSumApplyIteration(
		new GatherNeighborIds<>(valueTypeInfo),
		new SelectMinId<>(valueTypeInfo),
		new UpdateComponentId<>(valueTypeInfo),
		maxIterations).getVertices();
}
 
Example #10
Source File: TestMapEdges.java    From gelly-streaming with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithTupleType() throws Exception {
	/*
	 * Test mapEdges() converting the edge value type to tuple
     */
       final String resultPath = getTempDirPath("result");
       final String expectedResult = "1,2,(12,13)\n" +
               "1,3,(13,14)\n" +
               "2,3,(23,24)\n" +
               "3,4,(34,35)\n" +
               "3,5,(35,36)\n" +
               "4,5,(45,46)\n" +
               "5,1,(51,52)\n";
	final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

	GraphStream<Long, NullValue, Long> graph = new SimpleEdgeStream<>(GraphStreamTestUtils.getLongLongEdgeDataStream(env), env);
       graph.mapEdges(new ToTuple2Mapper())
               .getEdges()
               .writeAsCsv(resultPath, FileSystem.WriteMode.OVERWRITE);
	env.execute();
       compareResultsByLinesInMemory(expectedResult, resultPath);
   }
 
Example #11
Source File: CycleGraphTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testGraphMetrics() throws Exception {
	int vertexCount = 100;

	Graph<LongValue, NullValue, NullValue> graph = new CycleGraph(env, vertexCount)
		.generate();

	assertEquals(vertexCount, graph.numberOfVertices());
	assertEquals(2 * vertexCount, graph.numberOfEdges());

	long minInDegree = graph.inDegrees().min(1).collect().get(0).f1.getValue();
	long minOutDegree = graph.outDegrees().min(1).collect().get(0).f1.getValue();
	long maxInDegree = graph.inDegrees().max(1).collect().get(0).f1.getValue();
	long maxOutDegree = graph.outDegrees().max(1).collect().get(0).f1.getValue();

	assertEquals(2, minInDegree);
	assertEquals(2, minOutDegree);
	assertEquals(2, maxInDegree);
	assertEquals(2, maxOutDegree);
}
 
Example #12
Source File: GraphCreationWithCsvITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testCsvWithNullEdge() throws Exception {
	/*
	Test fromCsvReader with edge and vertex path and nullvalue for edge
	 */
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	final String vertexFileContent = "1,one\n" +
			"2,two\n" +
			"3,three\n";
	final String edgeFileContent = "1,2\n" +
			"3,2\n" +
			"3,1\n";
	final FileInputSplit split = createTempFile(vertexFileContent);
	final FileInputSplit edgeSplit = createTempFile(edgeFileContent);

	Graph<Long, String, NullValue> graph = Graph.fromCsvReader(split.getPath().toString(), edgeSplit.getPath().toString(),
			env).vertexTypes(Long.class, String.class);

	List<Triplet<Long, String, NullValue>> result = graph.getTriplets().collect();

	expectedResult = "1,2,one,two,(null)\n" +
			"3,2,three,two,(null)\n" +
			"3,1,three,one,(null)\n";

	compareResultAsTuples(result, expectedResult);
}
 
Example #13
Source File: SimplifyTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Before
@Override
public void setup() throws Exception{
	super.setup();

	Object[][] edges = new Object[][]{
		new Object[]{0, 0},
		new Object[]{0, 1},
		new Object[]{0, 1},
		new Object[]{0, 2},
		new Object[]{0, 2},
		new Object[]{1, 0},
		new Object[]{2, 2},
	};

	List<Edge<IntValue, NullValue>> edgeList = new LinkedList<>();

	for (Object[] edge : edges) {
		edgeList.add(new Edge<>(new IntValue((int) edge[0]), new IntValue((int) edge[1]), NullValue.getInstance()));
	}

	graph = Graph.fromCollection(edgeList, env);
}
 
Example #14
Source File: EdgeTargetDegreesTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithSimpleGraph() throws Exception {
	String expectedResult =
		"(0,1,((null),(3,0,3)))\n" +
		"(0,2,((null),(3,2,1)))\n" +
		"(2,1,((null),(3,0,3)))\n" +
		"(2,3,((null),(4,2,2)))\n" +
		"(3,1,((null),(3,0,3)))\n" +
		"(3,4,((null),(1,0,1)))\n" +
		"(5,3,((null),(4,2,2)))";

	DataSet<Edge<IntValue, Tuple2<NullValue, Degrees>>> targetDegrees = directedSimpleGraph
			.run(new EdgeTargetDegrees<>());

	TestBaseUtils.compareResultAsText(targetDegrees.collect(), expectedResult);
}
 
Example #15
Source File: VertexDegreeTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithEmptyGraphWithoutVertices() throws Exception {
	DataSet<Vertex<LongValue, LongValue>> degree;

	degree = emptyGraphWithoutVertices
		.run(new VertexDegree<LongValue, NullValue, NullValue>()
			.setIncludeZeroDegreeVertices(false));

	assertEquals(0, degree.collect().size());

	degree = emptyGraphWithoutVertices
		.run(new VertexDegree<LongValue, NullValue, NullValue>()
			.setIncludeZeroDegreeVertices(true));

	assertEquals(0, degree.collect().size());
}
 
Example #16
Source File: CirculantGraphTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testGraphMetrics() throws Exception {
	int vertexCount = 10;
	int offset = 4;
	int length = 2;

	Graph<LongValue, NullValue, NullValue> graph = new CirculantGraph(env, 10)
		.addRange(offset, length)
		.generate();

	assertEquals(vertexCount, graph.numberOfVertices());
	assertEquals(vertexCount * length, graph.numberOfEdges());

	long maxInDegree = graph.inDegrees().max(1).collect().get(0).f1.getValue();
	long maxOutDegree = graph.outDegrees().max(1).collect().get(0).f1.getValue();

	assertEquals(length, maxInDegree);
	assertEquals(length, maxOutDegree);
}
 
Example #17
Source File: SingletonEdgeGraphTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testGraphMetrics() throws Exception {
	int vertexPairCount = 10;

	Graph<LongValue, NullValue, NullValue> graph = new SingletonEdgeGraph(env, vertexPairCount)
		.generate();

	assertEquals(2 * vertexPairCount, graph.numberOfVertices());
	assertEquals(2 * vertexPairCount, graph.numberOfEdges());

	long minInDegree = graph.inDegrees().min(1).collect().get(0).f1.getValue();
	long minOutDegree = graph.outDegrees().min(1).collect().get(0).f1.getValue();
	long maxInDegree = graph.inDegrees().max(1).collect().get(0).f1.getValue();
	long maxOutDegree = graph.outDegrees().max(1).collect().get(0).f1.getValue();

	assertEquals(1, minInDegree);
	assertEquals(1, minOutDegree);
	assertEquals(1, maxInDegree);
	assertEquals(1, maxOutDegree);
}
 
Example #18
Source File: ValueArrayFactory.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Produce a {@code ValueArray} for the given {@code Value} type.
 *
 * @param cls {@code Value} class
 * @return {@code ValueArray} for given {@code Value} class
 */
@SuppressWarnings("unchecked")
public static <T> ValueArray<T> createValueArray(Class<? extends Value> cls) {
	if (ByteValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new ByteValueArray();
	} else if (CharValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new CharValueArray();
	} else if (DoubleValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new DoubleValueArray();
	} else if (FloatValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new FloatValueArray();
	} else if (IntValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new IntValueArray();
	} else if (LongValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new LongValueArray();
	} else if (NullValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new NullValueArray();
	} else if (ShortValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new ShortValueArray();
	} else if (StringValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new StringValueArray();
	} else {
		throw new IllegalArgumentException("Unable to create unbounded ValueArray for type " + cls);
	}
}
 
Example #19
Source File: ConnectedComponents.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public DataSet<Vertex<K, VV>> run(Graph<K, VV, EV> graph) throws Exception {

	// get type information for vertex value
	TypeInformation<VV> valueTypeInfo = ((TupleTypeInfo<?>) graph.getVertices().getType()).getTypeAt(1);

	Graph<K, VV, NullValue> undirectedGraph = graph
		.mapEdges(new MapTo<>(NullValue.getInstance()))
		.getUndirected();

	return undirectedGraph.runScatterGatherIteration(
		new CCMessenger<>(valueTypeInfo),
		new CCUpdater<>(),
		maxIterations).getVertices();
}
 
Example #20
Source File: GridGraph.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public void flatMap(LongValue source, Collector<Edge<LongValue, NullValue>> out)
		throws Exception {
	edge.f0 = source;
	long val = source.getValue();

	// the distance between neighbors in a given iteration
	long increment = vertexCount;

	// the value in the remaining dimensions
	long remainder = val;

	for (Tuple2<Long, Boolean> dimension : dimensions) {
		increment /= dimension.f0;

		// the index within this dimension
		long index = remainder / increment;

		if (index > 0) {
			target.setValue(val - increment);
			out.collect(edge);
		} else if (dimension.f1) {
			target.setValue(val + increment * (dimension.f0 - 1));
			out.collect(edge);
		}

		if (index < dimension.f0 - 1) {
			target.setValue(val + increment);
			out.collect(edge);
		} else if (dimension.f1) {
			target.setValue(val - increment * (dimension.f0 - 1));
			out.collect(edge);
		}

		remainder %= increment;
	}
}
 
Example #21
Source File: EdgeDegreePairTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testWithEmptyGraphWithVertices() throws Exception {
	DataSet<Edge<LongValue, Tuple3<NullValue, LongValue, LongValue>>> degreePairOnSourceId = emptyGraphWithVertices
		.run(new EdgeDegreePair<LongValue, NullValue, NullValue>()
			.setReduceOnTargetId(false));

	assertEquals(0, degreePairOnSourceId.collect().size());

	DataSet<Edge<LongValue, Tuple3<NullValue, LongValue, LongValue>>> degreePairOnTargetId = emptyGraphWithVertices
		.run(new EdgeDegreePair<LongValue, NullValue, NullValue>()
			.setReduceOnTargetId(true));

	assertEquals(0, degreePairOnTargetId.collect().size());
}
 
Example #22
Source File: WindowTriangles.java    From gelly-streaming with Apache License 2.0 5 votes vote down vote up
@Override
public void applyOnEdges(Long vertexID,
		Iterable<Tuple2<Long, NullValue>> neighbors,
		Collector<Tuple3<Long, Long, Boolean>> out) throws Exception {

	Tuple3<Long, Long, Boolean> outT = new Tuple3<>();
	outT.setField(vertexID, 0);
	outT.setField(false, 2); //isCandidate=false

	Set<Long> neighborIdsSet = new HashSet<Long>();
	for (Tuple2<Long, NullValue> t: neighbors) {
		outT.setField(t.f0, 1);
		out.collect(outT);
		neighborIdsSet.add(t.f0);
	}
	Object[] neighborIds = neighborIdsSet.toArray();
	neighborIdsSet.clear();
	outT.setField(true, 2); //isCandidate=true
	for (int i=0; i<neighborIds.length-1; i++) {
		for (int j=i; j<neighborIds.length; j++) {
			// only emit the candidates
			// with IDs larger than the vertex ID
			if (((long)neighborIds[i] > vertexID) && ((long)neighborIds[j] > vertexID)) {
				outT.setField((long)neighborIds[i], 0);
				outT.setField((long)neighborIds[j], 1);
				out.collect(outT);
			}
		}
	}
}
 
Example #23
Source File: TriangleListingTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testSimpleGraphPermuted() throws Exception {
	DataSet<Result<IntValue>> tl = undirectedSimpleGraph
		.run(new TriangleListing<IntValue, NullValue, NullValue>()
			.setPermuteResults(true));

	String expectedResult =
		// permutation of (0,1,2)
		"1st vertex ID: 0, 2nd vertex ID: 1, 3rd vertex ID: 2\n" +
		"1st vertex ID: 0, 2nd vertex ID: 2, 3rd vertex ID: 1\n" +
		"1st vertex ID: 1, 2nd vertex ID: 0, 3rd vertex ID: 2\n" +
		"1st vertex ID: 1, 2nd vertex ID: 2, 3rd vertex ID: 0\n" +
		"1st vertex ID: 2, 2nd vertex ID: 0, 3rd vertex ID: 1\n" +
		"1st vertex ID: 2, 2nd vertex ID: 1, 3rd vertex ID: 0\n" +
		// permutation of (1,2,3)
		"1st vertex ID: 1, 2nd vertex ID: 2, 3rd vertex ID: 3\n" +
		"1st vertex ID: 1, 2nd vertex ID: 3, 3rd vertex ID: 2\n" +
		"1st vertex ID: 2, 2nd vertex ID: 1, 3rd vertex ID: 3\n" +
		"1st vertex ID: 2, 2nd vertex ID: 3, 3rd vertex ID: 1\n" +
		"1st vertex ID: 3, 2nd vertex ID: 1, 3rd vertex ID: 2\n" +
		"1st vertex ID: 3, 2nd vertex ID: 2, 3rd vertex ID: 1";

	List<String> printableStrings = new ArrayList<>();

	for (Result<IntValue> result : tl.collect()) {
		printableStrings.add(result.toPrintableString());
	}

	TestBaseUtils.compareResultAsText(printableStrings, expectedResult);
}
 
Example #24
Source File: EdgeDegreePairTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testWithSimpleGraph() throws Exception {
	String expectedResult =
		"(0,1,((null),2,3))\n" +
		"(0,2,((null),2,3))\n" +
		"(1,0,((null),3,2))\n" +
		"(1,2,((null),3,3))\n" +
		"(1,3,((null),3,4))\n" +
		"(2,0,((null),3,2))\n" +
		"(2,1,((null),3,3))\n" +
		"(2,3,((null),3,4))\n" +
		"(3,1,((null),4,3))\n" +
		"(3,2,((null),4,3))\n" +
		"(3,4,((null),4,1))\n" +
		"(3,5,((null),4,1))\n" +
		"(4,3,((null),1,4))\n" +
		"(5,3,((null),1,4))";

	DataSet<Edge<IntValue, Tuple3<NullValue, LongValue, LongValue>>> degreePairOnSourceId = undirectedSimpleGraph
		.run(new EdgeDegreePair<IntValue, NullValue, NullValue>()
			.setReduceOnTargetId(false));

	TestBaseUtils.compareResultAsText(degreePairOnSourceId.collect(), expectedResult);

	DataSet<Edge<IntValue, Tuple3<NullValue, LongValue, LongValue>>> degreePairOnTargetId = undirectedSimpleGraph
		.run(new EdgeDegreePair<IntValue, NullValue, NullValue>()
			.setReduceOnTargetId(true));

	TestBaseUtils.compareResultAsText(degreePairOnTargetId.collect(), expectedResult);
}
 
Example #25
Source File: TriadicCensusTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@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 #26
Source File: GeneratedMultiGraph.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public Graph<LongValue, NullValue, NullValue> create(ExecutionEnvironment env)
		throws Exception {
	Graph<LongValue, NullValue, NullValue> graph = generate(env);

	// simplify after the translation to improve the performance of the
	// simplify operators by processing smaller data types
	return simplify.simplify(graph, parallelism.getValue().intValue());
}
 
Example #27
Source File: EdgeDegreePairTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testWithEmptyGraphWithVertices() throws Exception {
	DataSet<Edge<LongValue, Tuple3<NullValue, LongValue, LongValue>>> degreePairOnSourceId = emptyGraphWithVertices
		.run(new EdgeDegreePair<LongValue, NullValue, NullValue>()
			.setReduceOnTargetId(false));

	assertEquals(0, degreePairOnSourceId.collect().size());

	DataSet<Edge<LongValue, Tuple3<NullValue, LongValue, LongValue>>> degreePairOnTargetId = emptyGraphWithVertices
		.run(new EdgeDegreePair<LongValue, NullValue, NullValue>()
			.setReduceOnTargetId(true));

	assertEquals(0, degreePairOnTargetId.collect().size());
}
 
Example #28
Source File: TriangleListingTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testSimpleGraphSorted() throws Exception {
	DataSet<Result<IntValue>> tl = directedSimpleGraph
		.run(new TriangleListing<IntValue, NullValue, NullValue>()
			.setSortTriangleVertices(true));

	String expectedResult =
		"(0,1,2,41)\n" +
		"(1,2,3,22)";

	TestBaseUtils.compareResultAsText(tl.collect(), expectedResult);
}
 
Example #29
Source File: EchoGraphTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testParallelism() throws Exception {
	int parallelism = 2;

	Graph<LongValue, NullValue, NullValue> graph = new EchoGraph(env, 10, 3)
		.setParallelism(parallelism)
		.generate();

	graph.getVertices().output(new DiscardingOutputFormat<>());
	graph.getEdges().output(new DiscardingOutputFormat<>());

	TestUtils.verifyParallelism(env, parallelism);
}
 
Example #30
Source File: CirculantGraphTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testGraph() throws Exception {
	Graph<LongValue, NullValue, NullValue> graph = new CirculantGraph(env, 10)
		.addRange(4, 3)
		.generate();

	String vertices = "0; 1; 2; 3; 4; 5; 6; 7; 8; 9";
	String edges = "0,4; 0,5; 0,6; 1,5; 1,6; 1,7; 2,6;" +
		"2,7; 2,8; 3,7; 3,8; 3,9; 4,0; 4,8; 4,9;" +
		"5,0; 5,1; 5,9; 6,0; 6,1; 6,2; 7,1; 7,2; 7,3;" +
		"8,2; 8,3; 8,4; 9,3; 9,4; 9,5";

	TestUtils.compareGraph(graph, vertices, edges);
}