當前位置: 首頁>>代碼示例>>Java>>正文


Java Triad類代碼示例

本文整理匯總了Java中org.apache.flink.examples.java.graph.util.EnumTrianglesDataTypes.Triad的典型用法代碼示例。如果您正苦於以下問題:Java Triad類的具體用法?Java Triad怎麽用?Java Triad使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Triad類屬於org.apache.flink.examples.java.graph.util.EnumTrianglesDataTypes包,在下文中一共展示了Triad類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: reduce

import org.apache.flink.examples.java.graph.util.EnumTrianglesDataTypes.Triad; //導入依賴的package包/類
@Override
public void reduce(Iterable<Edge> edgesIter, Collector<Triad> out) throws Exception {

	final Iterator<Edge> edges = edgesIter.iterator();

	// clear vertex list
	vertices.clear();

	// read first edge
	Edge firstEdge = edges.next();
	outTriad.setFirstVertex(firstEdge.getFirstVertex());
	vertices.add(firstEdge.getSecondVertex());

	// build and emit triads
	while (edges.hasNext()) {
		Integer higherVertexId = edges.next().getSecondVertex();

		// combine vertex with all previously read vertices
		for (Integer lowerVertexId : vertices) {
			outTriad.setSecondVertex(lowerVertexId);
			outTriad.setThirdVertex(higherVertexId);
			out.collect(outTriad);
		}
		vertices.add(higherVertexId);
	}
}
 
開發者ID:axbaretto,項目名稱:flink,代碼行數:27,代碼來源:EnumTriangles.java

示例2: reduce

import org.apache.flink.examples.java.graph.util.EnumTrianglesDataTypes.Triad; //導入依賴的package包/類
@Override
public void reduce(Iterable<Edge> edgesIter, Collector<Triad> out) throws Exception {
	
	final Iterator<Edge> edges = edgesIter.iterator();
	
	// clear vertex list
	vertices.clear();
	
	// read first edge
	Edge firstEdge = edges.next();
	outTriad.setFirstVertex(firstEdge.getFirstVertex());
	vertices.add(firstEdge.getSecondVertex());
	
	// build and emit triads
	while (edges.hasNext()) {
		Integer higherVertexId = edges.next().getSecondVertex();
		
		// combine vertex with all previously read vertices
		for (Integer lowerVertexId : vertices) {
			outTriad.setSecondVertex(lowerVertexId);
			outTriad.setThirdVertex(higherVertexId);
			out.collect(outTriad);
		}
		vertices.add(higherVertexId);
	}
}
 
開發者ID:citlab,項目名稱:vs.msc.ws14,代碼行數:27,代碼來源:EnumTrianglesBasic.java

示例3: reduce

import org.apache.flink.examples.java.graph.util.EnumTrianglesDataTypes.Triad; //導入依賴的package包/類
@Override
public void reduce(Iterable<Edge> edgesIter, Collector<Triad> out) throws Exception {
	final Iterator<Edge> edges = edgesIter.iterator();
	
	// clear vertex list
	vertices.clear();
	
	// read first edge
	Edge firstEdge = edges.next();
	outTriad.setFirstVertex(firstEdge.getFirstVertex());
	vertices.add(firstEdge.getSecondVertex());
	
	// build and emit triads
	while (edges.hasNext()) {
		Integer higherVertexId = edges.next().getSecondVertex();
		
		// combine vertex with all previously read vertices
		for(Integer lowerVertexId : vertices) {
			outTriad.setSecondVertex(lowerVertexId);
			outTriad.setThirdVertex(higherVertexId);
			out.collect(outTriad);
		}
		vertices.add(higherVertexId);
	}
}
 
開發者ID:citlab,項目名稱:vs.msc.ws14,代碼行數:26,代碼來源:EnumTrianglesOpt.java

示例4: main

import org.apache.flink.examples.java.graph.util.EnumTrianglesDataTypes.Triad; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
	
	if(!parseParameters(args)) {
		return;
	}
	
	// set up execution environment
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	// read input data
	DataSet<Edge> edges = getEdgeDataSet(env);
	
	// project edges by vertex id
	DataSet<Edge> edgesById = edges
			.map(new EdgeByIdProjector());
	
	DataSet<Triad> triangles = edgesById
			// build triads
			.groupBy(Edge.V1).sortGroup(Edge.V2, Order.ASCENDING).reduceGroup(new TriadBuilder())
			// filter triads
			.join(edgesById).where(Triad.V2, Triad.V3).equalTo(Edge.V1, Edge.V2).with(new TriadFilter());

	// emit result
	if(fileOutput) {
		triangles.writeAsCsv(outputPath, "\n", ",");
	} else {
		triangles.print();
	}

	// execute program
	env.execute("Basic Triangle Enumeration Example");

}
 
開發者ID:citlab,項目名稱:vs.msc.ws14,代碼行數:34,代碼來源:EnumTrianglesBasic.java

示例5: main

import org.apache.flink.examples.java.graph.util.EnumTrianglesDataTypes.Triad; //導入依賴的package包/類
public static void main(String[] args) throws Exception {

		// Checking input parameters
		final ParameterTool params = ParameterTool.fromArgs(args);

		// set up execution environment
		final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

		// make parameters available in the web interface
		env.getConfig().setGlobalJobParameters(params);

		// read input data
		DataSet<Edge> edges;
		if (params.has("edges")) {
			edges = env.readCsvFile(params.get("edges"))
					.fieldDelimiter(" ")
					.includeFields(true, true)
					.types(Integer.class, Integer.class)
					.map(new TupleEdgeConverter());
		} else {
			System.out.println("Executing EnumTriangles example with default edges data set.");
			System.out.println("Use --edges to specify file input.");
			edges = EnumTrianglesData.getDefaultEdgeDataSet(env);
		}

		// project edges by vertex id
		DataSet<Edge> edgesById = edges
				.map(new EdgeByIdProjector());

		DataSet<Triad> triangles = edgesById
				// build triads
				.groupBy(Edge.V1).sortGroup(Edge.V2, Order.ASCENDING).reduceGroup(new TriadBuilder())
				// filter triads
				.join(edgesById).where(Triad.V2, Triad.V3).equalTo(Edge.V1, Edge.V2).with(new TriadFilter());

		// emit result
		if (params.has("output")) {
			triangles.writeAsCsv(params.get("output"), "\n", ",");
			// execute program
			env.execute("Basic Triangle Enumeration Example");
		} else {
			System.out.println("Printing result to stdout. Use --output to specify output path.");
			triangles.print();
		}
	}
 
開發者ID:axbaretto,項目名稱:flink,代碼行數:46,代碼來源:EnumTriangles.java

示例6: join

import org.apache.flink.examples.java.graph.util.EnumTrianglesDataTypes.Triad; //導入依賴的package包/類
@Override
public Triad join(Triad triad, Edge edge) throws Exception {
	return triad;
}
 
開發者ID:axbaretto,項目名稱:flink,代碼行數:5,代碼來源:EnumTriangles.java

示例7: main

import org.apache.flink.examples.java.graph.util.EnumTrianglesDataTypes.Triad; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
	
	if(!parseParameters(args)) {
		return;
	}
	
	// set up execution environment
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	
	// read input data
	DataSet<Edge> edges = getEdgeDataSet(env);
	
	// annotate edges with degrees
	DataSet<EdgeWithDegrees> edgesWithDegrees = edges
			.flatMap(new EdgeDuplicator())
			.groupBy(Edge.V1).sortGroup(Edge.V2, Order.ASCENDING).reduceGroup(new DegreeCounter())
			.groupBy(EdgeWithDegrees.V1,EdgeWithDegrees.V2).reduce(new DegreeJoiner());
	
	// project edges by degrees
	DataSet<Edge> edgesByDegree = edgesWithDegrees
			.map(new EdgeByDegreeProjector());
	// project edges by vertex id
	DataSet<Edge> edgesById = edgesByDegree
			.map(new EdgeByIdProjector());
	
	DataSet<Triad> triangles = edgesByDegree
			// build triads
			.groupBy(Edge.V1).sortGroup(Edge.V2, Order.ASCENDING).reduceGroup(new TriadBuilder())
			// filter triads
			.join(edgesById).where(Triad.V2,Triad.V3).equalTo(Edge.V1,Edge.V2).with(new TriadFilter());

	// emit result
	if(fileOutput) {
		triangles.writeAsCsv(outputPath, "\n", ",");
	} else {
		triangles.print();
	}
	
	// execute program
	env.execute("Triangle Enumeration Example");
	
}
 
開發者ID:citlab,項目名稱:vs.msc.ws14,代碼行數:43,代碼來源:EnumTrianglesOpt.java


注:本文中的org.apache.flink.examples.java.graph.util.EnumTrianglesDataTypes.Triad類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。