当前位置: 首页>>代码示例>>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;未经允许,请勿转载。