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


Java GraphStructure類代碼示例

本文整理匯總了Java中science.atlarge.graphalytics.validation.GraphStructure的典型用法代碼示例。如果您正苦於以下問題:Java GraphStructure類的具體用法?Java GraphStructure怎麽用?Java GraphStructure使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


GraphStructure類屬於science.atlarge.graphalytics.validation包,在下文中一共展示了GraphStructure類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: execute

import science.atlarge.graphalytics.validation.GraphStructure; //導入依賴的package包/類
private PageRankOutput execute(GraphStructure graph, PageRankParameters parameters, boolean directed)
		throws Exception {
	File edgesFile = File.createTempFile("edges.", ".txt");
	File verticesFile = File.createTempFile("vertices.", ".txt");
	File outputFile = File.createTempFile("output.", ".txt");

	Utils.writeEdgeToFile(graph, directed, edgesFile);
	Utils.writeVerticesToFile(graph, verticesFile);

	String jobId = "RandomJobId";
	String logPath = "RandomLogDir";

	PageRankJob job = new PageRankJob(
			Utils.loadConfiguration(),
			verticesFile.getAbsolutePath(), edgesFile.getAbsolutePath(),
			directed, parameters, jobId, logPath);
	job.setOutputFile(outputFile);
	job.run();
	
	return new PageRankOutput(Utils.readResults(outputFile, Double.class));
}
 
開發者ID:atlarge-research,項目名稱:graphalytics-platforms-powergraph,代碼行數:22,代碼來源:PageRankJobTestIT.java

示例2: execute

import science.atlarge.graphalytics.validation.GraphStructure; //導入依賴的package包/類
private LocalClusteringCoefficientOutput execute(GraphStructure graph, boolean directed) throws Exception {
	File edgesFile = File.createTempFile("edges.", ".txt");
	File verticesFile = File.createTempFile("vertices.", ".txt");
	File outputFile = File.createTempFile("output.", ".txt");

	Utils.writeEdgeToFile(graph, directed, edgesFile);
	Utils.writeVerticesToFile(graph, verticesFile);

	String jobId = "RandomJobId";
	String logPath = "RandomLogDir";

	LocalClusteringCoefficientJob job = new LocalClusteringCoefficientJob(
			Utils.loadConfiguration(),
			verticesFile.getAbsolutePath(), edgesFile.getAbsolutePath(),
			directed, jobId, logPath);
	job.setOutputFile(outputFile);
	job.run();
	
	return new LocalClusteringCoefficientOutput(Utils.readResults(outputFile, Double.class));
}
 
開發者ID:atlarge-research,項目名稱:graphalytics-platforms-powergraph,代碼行數:21,代碼來源:LocalClusteringCoefficientJobTestIT.java

示例3: execute

import science.atlarge.graphalytics.validation.GraphStructure; //導入依賴的package包/類
private CommunityDetectionLPOutput execute(GraphStructure graph, CommunityDetectionLPParameters parameters,
		boolean directed) throws Exception {
	File edgesFile = File.createTempFile("edges.", ".txt");
	File verticesFile = File.createTempFile("vertices.", ".txt");
	File outputFile = File.createTempFile("output.", ".txt");

	Utils.writeEdgeToFile(graph, directed, edgesFile);
	Utils.writeVerticesToFile(graph, verticesFile);

	String jobId = "RandomJobId";
	String logPath = "RandomLogDir";

	CommunityDetectionJob job = new CommunityDetectionJob(
			Utils.loadConfiguration(),
			verticesFile.getAbsolutePath(), edgesFile.getAbsolutePath(),
			directed, parameters, jobId, logPath);
	job.setOutputFile(outputFile);
	job.run();
	
	return new CommunityDetectionLPOutput(Utils.readResults(outputFile, Long.class));
}
 
開發者ID:atlarge-research,項目名稱:graphalytics-platforms-powergraph,代碼行數:22,代碼來源:CommunityDetectionLPJobTestIT.java

示例4: execute

import science.atlarge.graphalytics.validation.GraphStructure; //導入依賴的package包/類
private BreadthFirstSearchOutput execute(GraphStructure graph,
		BreadthFirstSearchParameters parameters, boolean directed) throws Exception {
	File edgesFile = File.createTempFile("edges.", ".txt");
	File verticesFile = File.createTempFile("vertices.", ".txt");
	File outputFile = File.createTempFile("output.", ".txt");

	Utils.writeEdgeToFile(graph, directed, edgesFile);
	Utils.writeVerticesToFile(graph, verticesFile);

	String jobId = "RandomJobId";
	String logPath = "RandomLogDir";

	BreadthFirstSearchJob job = new BreadthFirstSearchJob(
			Utils.loadConfiguration(),
			verticesFile.getAbsolutePath(), edgesFile.getAbsolutePath(),
			directed, parameters, jobId, logPath);
	job.setOutputFile(outputFile);
	job.run();
	
	return new BreadthFirstSearchOutput(Utils.readResults(outputFile, Long.class));
}
 
開發者ID:atlarge-research,項目名稱:graphalytics-platforms-powergraph,代碼行數:22,代碼來源:BreadthFirstSearchJobTestIT.java

示例5: execute

import science.atlarge.graphalytics.validation.GraphStructure; //導入依賴的package包/類
private WeaklyConnectedComponentsOutput execute(GraphStructure graph, boolean directed) throws Exception {
	File edgesFile = File.createTempFile("edges.", ".txt");
	File verticesFile = File.createTempFile("vertices.", ".txt");
	File outputFile = File.createTempFile("output.", ".txt");

	Utils.writeEdgeToFile(graph, directed, edgesFile);
	Utils.writeVerticesToFile(graph, verticesFile);

	String jobId = "RandomJobId";
	String logPath = "RandomLogDir";

	ConnectedComponentsJob job = new ConnectedComponentsJob(
			Utils.loadConfiguration(),
			verticesFile.getAbsolutePath(), edgesFile.getAbsolutePath(),
			directed, jobId, logPath);
	job.setOutputFile(outputFile);
	job.run();
	
	return new WeaklyConnectedComponentsOutput(Utils.readResults(outputFile, Long.class));
}
 
開發者ID:atlarge-research,項目名稱:graphalytics-platforms-powergraph,代碼行數:21,代碼來源:WeaklyConnectedComponentsJobTestIT.java

示例6: deduplicateNewUndirectedEdges

import science.atlarge.graphalytics.validation.GraphStructure; //導入依賴的package包/類
/**
 * Turns newly-added edges from an undirected graph into directed edges by removing the edges in the direction of
 * new vertices. This results in a directed graph that could have been the result of executing the directed forest
 * fire model algorithm on the input graph. As a result, the corrected undirected graph can be validated as a
 * directed graph, reducing code duplication.
 *
 * @param result            the output of the undirected forest fire model algorithm
 * @param maximumOriginalId the largest vertex id in the input graph
 * @return the correct graph
 */
private static GraphStructure deduplicateNewUndirectedEdges(GraphStructure result, long maximumOriginalId) {
	Map<Long, Set<Long>> edges = new HashMap<>();
	for (long vertexId : result.getVertices()) {
		edges.put(vertexId, new HashSet<>(result.getEdgesForVertex(vertexId)));
	}

	for (long sourceId : result.getVertices()) {
		if (sourceId > maximumOriginalId) {
			for (long destinationId : result.getEdgesForVertex(sourceId)) {
				if (destinationId < sourceId) {
					assertThat("edge from " + sourceId + " to " + destinationId + " is undirected",
							sourceId, isIn(edges.get(destinationId)));
					edges.get(destinationId).remove(sourceId);
				}
			}
		}
	}

	return new GraphStructure(edges);
}
 
開發者ID:ldbc,項目名稱:ldbc_graphalytics,代碼行數:31,代碼來源:ForestFireModelValidationTest.java

示例7: testDirectedForestFireModelOnValidationGraph

import science.atlarge.graphalytics.validation.GraphStructure; //導入依賴的package包/類
@Test
public final void testDirectedForestFireModelOnValidationGraph() throws Exception {
	final String inputPath = "/validation-graphs/ffm/dir-input";
	final long maximumVertexId = 50;
	final float pRatio = 0.5f;
	final float rRatio = 0.5f;
	final int numberOfIterations = 2;
	final int numberOfNewVertices = 5;

	GraphStructure inputGraph = GraphParser.parseGraphStructureFromVertexBasedDataset(
			getClass().getResourceAsStream(inputPath), true);

	ForestFireModelParameters parameters = new ForestFireModelParameters(maximumVertexId, pRatio, rRatio,
			numberOfIterations, numberOfNewVertices);
	GraphStructure executionResult = executeDirectedForestFireModel(inputGraph, parameters);

	validateForestFireModel(inputGraph, executionResult, maximumVertexId, numberOfNewVertices, numberOfIterations,
			true);
}
 
開發者ID:ldbc,項目名稱:ldbc_graphalytics,代碼行數:20,代碼來源:ForestFireModelValidationTest.java

示例8: testUndirectedForestFireModelOnValidationGraph

import science.atlarge.graphalytics.validation.GraphStructure; //導入依賴的package包/類
@Test
public final void testUndirectedForestFireModelOnValidationGraph() throws Exception {
	final String inputPath = "/validation-graphs/ffm/undir-input";
	final long maximumVertexId = 50;
	final float pRatio = 0.5f;
	final float rRatio = 0.5f;
	final int numberOfIterations = 2;
	final int numberOfNewVertices = 5;

	GraphStructure inputGraph = GraphParser.parseGraphStructureFromVertexBasedDataset(
			getClass().getResourceAsStream(inputPath), true);

	ForestFireModelParameters parameters = new ForestFireModelParameters(maximumVertexId, pRatio, rRatio,
			numberOfIterations, numberOfNewVertices);
	GraphStructure executionResult = executeUndirectedForestFireModel(inputGraph, parameters);

	validateForestFireModel(inputGraph, executionResult, maximumVertexId, numberOfNewVertices, numberOfIterations,
			false);
}
 
開發者ID:ldbc,項目名稱:ldbc_graphalytics,代碼行數:20,代碼來源:ForestFireModelValidationTest.java

示例9: validateForestFireModel

import science.atlarge.graphalytics.validation.GraphStructure; //導入依賴的package包/類
/**
 * Validates the output of a forest fire model implementation.
 *
 * @param inputGraph          the input graph
 * @param outputGraph         the output if the forest fire model implementation
 * @param maximumOriginalId   the largest vertex id in the input graph
 * @param numberOfNewVertices the number of new vertices that should have been added
 * @param numberOfIterations  the number of iterations for which the algorithm should have been run
 * @param graphIsDirected     true iff the input graph is directed
 */
private void validateForestFireModel(GraphStructure inputGraph, GraphStructure outputGraph, long maximumOriginalId,
                                     int numberOfNewVertices, int numberOfIterations, boolean graphIsDirected) {
	if (!graphIsDirected) {
		outputGraph = deduplicateNewUndirectedEdges(outputGraph, maximumOriginalId);
	}

	verifyOriginalGraphUnchanged(inputGraph, outputGraph);

	verifyNewVerticesCreated(inputGraph, outputGraph, maximumOriginalId, numberOfNewVertices);

	long firstNewVertexId = maximumOriginalId + 1;
	long lastNewVertexId = maximumOriginalId + numberOfNewVertices;
	for (long newVertexId = firstNewVertexId; newVertexId <= lastNewVertexId; newVertexId++) {
		verifyNewEdgesAreFeasible(inputGraph, outputGraph, newVertexId, numberOfIterations);
	}
}
 
開發者ID:ldbc,項目名稱:ldbc_graphalytics,代碼行數:27,代碼來源:ForestFireModelValidationTest.java

示例10: writeVerticesToFile

import science.atlarge.graphalytics.validation.GraphStructure; //導入依賴的package包/類
public static void writeVerticesToFile(GraphStructure graph, File f) throws IOException {
	BufferedWriter w = new BufferedWriter(new FileWriter(f));
	
	for (long v: graph.getVertices()) {
		w.write(String.format("%d\n", v));
	}
	
	w.flush();
	w.close();
}
 
開發者ID:atlarge-research,項目名稱:graphalytics-platforms-powergraph,代碼行數:11,代碼來源:Utils.java

示例11: writeEdgeToFile

import science.atlarge.graphalytics.validation.GraphStructure; //導入依賴的package包/類
public static void writeEdgeToFile(GraphStructure graph, boolean directed, File f) throws IOException {
	BufferedWriter w = new BufferedWriter(new FileWriter(f));
	
	for (long v: graph.getVertices()) {
		for (long u: graph.getEdgesForVertex(v)) {
			if (directed || v < u) {
				w.write(String.format("%d %d\n", v, u));
			}
		}
	}
	
	w.flush();
	w.close();
}
 
開發者ID:atlarge-research,項目名稱:graphalytics-platforms-powergraph,代碼行數:15,代碼來源:Utils.java

示例12: testDirectedPageRankOnValidationGraph

import science.atlarge.graphalytics.validation.GraphStructure; //導入依賴的package包/類
@Test
public final void testDirectedPageRankOnValidationGraph() throws Exception {
	final String inputPath = "/validation-graphs/pr/dir-input";
	final String outputPath = "/validation-graphs/pr/dir-output";
	final float dampingFactor = 0.85f;
	final int numberOfIterations = 14;

	GraphStructure inputGraph = GraphParser.parseGraphStructureFromVertexBasedDataset(
			getClass().getResourceAsStream(inputPath), true);

	PageRankParameters parameters = new PageRankParameters(dampingFactor, numberOfIterations);
	PageRankOutput executionResult = executeDirectedPageRank(inputGraph, parameters);

	validatePageRank(executionResult, outputPath);
}
 
開發者ID:ldbc,項目名稱:ldbc_graphalytics,代碼行數:16,代碼來源:PageRankValidationTest.java

示例13: testUndirectedPageRankOnValidationGraph

import science.atlarge.graphalytics.validation.GraphStructure; //導入依賴的package包/類
@Test
public final void testUndirectedPageRankOnValidationGraph() throws Exception {
	final String inputPath = "/validation-graphs/pr/undir-input";
	final String outputPath = "/validation-graphs/pr/undir-output";
	final float dampingFactor = 0.85f;
	final int numberOfIterations = 26;

	GraphStructure inputGraph = GraphParser.parseGraphStructureFromVertexBasedDataset(
			getClass().getResourceAsStream(inputPath), true);

	PageRankParameters parameters = new PageRankParameters(dampingFactor, numberOfIterations);
	PageRankOutput executionResult = executeUndirectedPageRank(inputGraph, parameters);

	validatePageRank(executionResult, outputPath);
}
 
開發者ID:ldbc,項目名稱:ldbc_graphalytics,代碼行數:16,代碼來源:PageRankValidationTest.java

示例14: verifyOriginalGraphUnchanged

import science.atlarge.graphalytics.validation.GraphStructure; //導入依賴的package包/類
/**
 * Verifies that the vertices in the input graph still exist in the output, and that no edges were added or removed
 * between these vertices.
 *
 * @param original the input graph
 * @param result   the output graph
 */
private static void verifyOriginalGraphUnchanged(GraphStructure original, GraphStructure result) {
	assertThat("original vertices still exist",
			original.getVertices(), everyItem(isIn(result.getVertices())));
	for (long vertexId : original.getVertices()) {
		Set<Long> originalEdges = result.getEdgesForVertex(vertexId);
		Set<Long> resultEdges = result.getEdgesForVertex(vertexId);

		assertThat("original vertex " + vertexId + " did not gain or lose any edges",
				resultEdges, is(equalTo(originalEdges)));
	}
}
 
開發者ID:ldbc,項目名稱:ldbc_graphalytics,代碼行數:19,代碼來源:ForestFireModelValidationTest.java

示例15: verifyNewVerticesCreated

import science.atlarge.graphalytics.validation.GraphStructure; //導入依賴的package包/類
/**
 * Verifies that the correct number of new vertices were created and that they have the expected vertex ids.
 *
 * @param original            the input graph
 * @param result              the output graph
 * @param maximumOriginalId   the highest vertex id in the input graph
 * @param numberOfNewVertices the number of vertices that should have been created
 */
private static void verifyNewVerticesCreated(GraphStructure original, GraphStructure result,
                                             long maximumOriginalId, int numberOfNewVertices) {
	assertThat("correct number of new vertices were created",
			result.getVertices(), hasSize(original.getVertices().size() + numberOfNewVertices));
	for (long vertexId = maximumOriginalId + 1; vertexId <= maximumOriginalId + numberOfNewVertices; vertexId++) {
		assertThat("vertex with id " + vertexId + " is created",
				vertexId, isIn(result.getVertices()));
	}
}
 
開發者ID:ldbc,項目名稱:ldbc_graphalytics,代碼行數:18,代碼來源:ForestFireModelValidationTest.java


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