本文整理汇总了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));
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
示例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();
}
示例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();
}
示例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);
}
示例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);
}
示例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)));
}
}
示例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()));
}
}