@Test public void testGraphWithSameScore() throws Exception { LogicalGraph specialGraph = getLoaderFromString( "(alice:Person {name : \"Alice\"})\n" + "(eve:Person {name : \"Eve\"})\n" + "g0:Community {interest : \"Friends\", vertexCount : 2} [\n" + "(eve)-[eka:knows {since : 2013}]->(alice)\n" + "(alice)-[ake:knows {since : 2013}]->(eve)]").getLogicalGraphByVariable("g0"); LogicalGraph sampledGraph = getSamplingOperator().sample(specialGraph); validateGraph(specialGraph, sampledGraph); validateSpecific(specialGraph, sampledGraph); }
@Override public LogicalGraph sample(LogicalGraph graph) { LogicalGraph pageRankGraph = new PageRank( SamplingConstants.PAGE_RANK_SCORE_PROPERTY_KEY, dampeningFactor, maxIteration, true).execute(graph); graph = graph.getFactory().fromDataSets( graph.getGraphHead(), pageRankGraph.getVertices(), pageRankGraph.getEdges()); graph = graph .aggregate(new MinVertexProperty(SamplingConstants.PAGE_RANK_SCORE_PROPERTY_KEY), new MaxVertexProperty(SamplingConstants.PAGE_RANK_SCORE_PROPERTY_KEY), new SumVertexProperty(SamplingConstants.PAGE_RANK_SCORE_PROPERTY_KEY), new VertexCount()); DataSet<EPGMVertex> scaledVertices = graph.getVertices() .crossWithTiny(graph.getGraphHead().first(1)) .with(new AddPageRankScoresToVertexCrossFunction()) .filter(new PageRankResultVertexFilter( threshold, sampleGreaterThanThreshold, keepVerticesIfSameScore)); return graph.getFactory().fromDataSets(scaledVertices, graph.getEdges()).verify(); }
PageRankSampling extends SamplingAlgorithm { @Override public LogicalGraph sample(LogicalGraph graph) { LogicalGraph pageRankGraph = new PageRank( SamplingConstants.PAGE_RANK_SCORE_PROPERTY_KEY, dampeningFactor, maxIteration, true).execute(graph); graph = graph.getFactory().fromDataSets( graph.getGraphHead(), pageRankGraph.getVertices(), pageRankGraph.getEdges()); graph = graph .aggregate(new MinVertexProperty(SamplingConstants.PAGE_RANK_SCORE_PROPERTY_KEY), new MaxVertexProperty(SamplingConstants.PAGE_RANK_SCORE_PROPERTY_KEY), new SumVertexProperty(SamplingConstants.PAGE_RANK_SCORE_PROPERTY_KEY), new VertexCount()); DataSet<EPGMVertex> scaledVertices = graph.getVertices() .crossWithTiny(graph.getGraphHead().first(1)) .with(new AddPageRankScoresToVertexCrossFunction()) .filter(new PageRankResultVertexFilter( threshold, sampleGreaterThanThreshold, keepVerticesIfSameScore)); return graph.getFactory().fromDataSets(scaledVertices, graph.getEdges()).verify(); } }
PageRankSampling extends SamplingAlgorithm { @Override public LogicalGraph sample(LogicalGraph graph) { LogicalGraph pageRankGraph = new PageRank( SamplingConstants.PAGE_RANK_SCORE_PROPERTY_KEY, dampeningFactor, maxIteration, true).execute(graph); graph = graph.getFactory().fromDataSets( graph.getGraphHead(), pageRankGraph.getVertices(), pageRankGraph.getEdges()); graph = graph .aggregate(new MinVertexProperty(SamplingConstants.PAGE_RANK_SCORE_PROPERTY_KEY), new MaxVertexProperty(SamplingConstants.PAGE_RANK_SCORE_PROPERTY_KEY), new SumVertexProperty(SamplingConstants.PAGE_RANK_SCORE_PROPERTY_KEY), new VertexCount()); DataSet<EPGMVertex> scaledVertices = graph.getVertices() .crossWithTiny(graph.getGraphHead().first(1)) .with(new AddPageRankScoresToVertexCrossFunction()) .filter(new PageRankResultVertexFilter( threshold, sampleGreaterThanThreshold, keepVerticesIfSameScore)); return graph.getFactory().fromDataSets(scaledVertices, graph.getEdges()).verify(); } PageRankSampling(double dampeningFactor, int maxIteration, double threshold,
    boolean sampleGreaterThanThreshold, boolean keepVerticesIfSameScore); }
PageRankSampling extends SamplingAlgorithm { @Override public LogicalGraph sample(LogicalGraph graph) { LogicalGraph pageRankGraph = new PageRank( SamplingConstants.PAGE_RANK_SCORE_PROPERTY_KEY, dampeningFactor, maxIteration, true).execute(graph); graph = graph.getFactory().fromDataSets( graph.getGraphHead(), pageRankGraph.getVertices(), pageRankGraph.getEdges()); graph = graph .aggregate(new MinVertexProperty(SamplingConstants.PAGE_RANK_SCORE_PROPERTY_KEY), new MaxVertexProperty(SamplingConstants.PAGE_RANK_SCORE_PROPERTY_KEY), new SumVertexProperty(SamplingConstants.PAGE_RANK_SCORE_PROPERTY_KEY), new VertexCount()); DataSet<EPGMVertex> scaledVertices = graph.getVertices() .crossWithTiny(graph.getGraphHead().first(1)) .with(new AddPageRankScoresToVertexCrossFunction()) .filter(new PageRankResultVertexFilter( threshold, sampleGreaterThanThreshold, keepVerticesIfSameScore)); return graph.getFactory().fromDataSets(scaledVertices, graph.getEdges()).verify(); } PageRankSampling(double dampeningFactor, int maxIteration, double threshold,
    boolean sampleGreaterThanThreshold, boolean keepVerticesIfSameScore); @Override LogicalGraph sample(LogicalGraph graph); }
PageRankSampling extends SamplingAlgorithm { @Override public LogicalGraph sample(LogicalGraph graph) { LogicalGraph pageRankGraph = new PageRank( SamplingConstants.PAGE_RANK_SCORE_PROPERTY_KEY, dampeningFactor, maxIteration, true).execute(graph); graph = graph.getFactory().fromDataSets( graph.getGraphHead(), pageRankGraph.getVertices(), pageRankGraph.getEdges()); graph = graph .aggregate(new MinVertexProperty(SamplingConstants.PAGE_RANK_SCORE_PROPERTY_KEY), new MaxVertexProperty(SamplingConstants.PAGE_RANK_SCORE_PROPERTY_KEY), new SumVertexProperty(SamplingConstants.PAGE_RANK_SCORE_PROPERTY_KEY), new VertexCount()); DataSet<EPGMVertex> scaledVertices = graph.getVertices() .crossWithTiny(graph.getGraphHead().first(1)) .with(new AddPageRankScoresToVertexCrossFunction()) .filter(new PageRankResultVertexFilter( threshold, sampleGreaterThanThreshold, keepVerticesIfSameScore)); return graph.getFactory().fromDataSets(scaledVertices, graph.getEdges()).verify(); } PageRankSampling(double dampeningFactor, int maxIteration, double threshold,
    boolean sampleGreaterThanThreshold, boolean keepVerticesIfSameScore); @Override LogicalGraph sample(LogicalGraph graph);  }