@Override public boolean filter(V vertex) throws Exception { long degree = Long.parseLong(vertex.getPropertyValue(propertyNameOfDegree).toString()); long maxDegree = Long.parseLong(vertex.getPropertyValue(propertyNameofMaxDegree).toString()); return randomGenerator.nextFloat() <= (degree / (double) maxDegree) * threshold; } }
/** * Returns a escaped string representation of a property value. * * @param propertyValue property value to be escaped * @return escaped string representation */ private static String escape(PropertyValue propertyValue) { if (propertyValue.isString()) { return StringEscaper.escape(propertyValue.toString(), CSVConstants.ESCAPED_CHARACTERS); } return propertyValue.toString(); } }
/** * {@inheritDoc} */ @Override public boolean filter(V vertex) throws Exception { long degree = Long.parseLong(vertex.getPropertyValue(propertyNameOfDegree).toString()); long maxDegree = Long.parseLong(vertex.getPropertyValue(propertyNameofMaxDegree).toString()); return randomGenerator.nextFloat() <= (degree / (double) maxDegree) * threshold; } }
/** * Returns a escaped string representation of a property value. * * @param propertyValue property value to be escaped * @return escaped string representation */ private static String escape(PropertyValue propertyValue) { if (propertyValue.isString()) { return StringEscaper.escape(propertyValue.toString(), CSVConstants.ESCAPED_CHARACTERS); } return propertyValue.toString(); } }
@Override public boolean filter(V vertex) throws Exception { long degree = Long.parseLong(vertex.getPropertyValue(degreeType.getName()).toString()); if (degree > degreeThreshold) { return true; } else { return randomGenerator.nextFloat() <= threshold; } } }
/** * {@inheritDoc} */ @Override public boolean filter(V vertex) throws Exception { if (vertex.hasProperty(degreePropertyName)) { return Long.parseLong(vertex.getPropertyValue(degreePropertyName).toString()) != degree; } else { return true; } } }
@Override public boolean filter(V vertex) throws Exception { if (vertex.hasProperty(degreePropertyName)) { return Long.parseLong(vertex.getPropertyValue(degreePropertyName).toString()) != degree; } else { return true; } } }
/** * @param vertex the given vertex * @return the degree of that vertex */ @Override public Tuple1<Long> map(Vertex vertex) { return new Tuple1<>(Long.parseLong(vertex.getPropertyValue(nameOfDegreeProperty).toString())); } }
/** * {@inheritDoc} */ @Override public boolean filter(V vertex) throws Exception { long degree = Long.parseLong(vertex.getPropertyValue(degreeType.getName()).toString()); if (degree > degreeThreshold) { return true; } else { return randomGenerator.nextFloat() <= threshold; } } }
/** * @param vertex the given vertex * @return the degree of that vertex */ @Override public Tuple1<Long> map(Vertex vertex) { return new Tuple1<>(Long.parseLong(vertex.getPropertyValue(nameOfDegreeProperty).toString())); } }
@Override public PropertyValue getIncrement(Element vertex) { List<PropertyValue> valueList = new ArrayList<>(); valueList.add(PropertyValue.create(vertex.getPropertyValue(wccPropertyKey).toString())); return PropertyValue.create(valueList); }
@Override public PropertyValue getIncrement(Element vertex) { List<PropertyValue> valueList = new ArrayList<>(); valueList.add(PropertyValue.create(vertex.getPropertyValue(wccPropertyKey).toString())); return PropertyValue.create(valueList); }
@Override public PropertyValue getIncrement(Element edge) { List<PropertyValue> valueList = new ArrayList<>(); valueList.add(PropertyValue.create(edge.getPropertyValue(wccPropertyKey).toString())); return PropertyValue.create(valueList); }
@Override public PropertyValue getIncrement(Element edge) { List<PropertyValue> valueList = new ArrayList<>(); valueList.add(PropertyValue.create(edge.getPropertyValue(wccPropertyKey).toString())); return PropertyValue.create(valueList); }
@Override public PropertyValue getIncrement(Element vertex) { boolean isClosedQuotation = vertex.getLabel().equals("Quotation") && !vertex.getPropertyValue("status").toString().equals("open"); return PropertyValue.create(isClosedQuotation); } }
@Override public PropertyValue getIncrement(Element vertex) { return PropertyValue.create(vertex.getPropertyValue(PROPERTY_KEY_NAME).toString()); }
@Override public CCSGraph map(GraphTransaction graph) throws Exception { String category = graph.getGraphHead().getPropertyValue( CategoryCharacteristicSubgraphs.CATEGORY_KEY).toString(); Map<GradoopId, Integer> vertexIdMap = Maps.newHashMapWithExpectedSize(graph.getVertices().size()); Map<Integer, String> fsmVertices = transformVertices(graph, vertexIdMap); Map<Integer, FSMEdge> fsmEdges = transformEdges(graph, vertexIdMap); return new CCSGraph( category, graph.getGraphHead().getId(), fsmVertices, fsmEdges); } }
@Override public CCSGraph map(GraphTransaction graph) throws Exception { String category = graph.getGraphHead().getPropertyValue( CategoryCharacteristicSubgraphs.CATEGORY_KEY).toString(); Map<GradoopId, Integer> vertexIdMap = Maps.newHashMapWithExpectedSize(graph.getVertices().size()); Map<Integer, String> fsmVertices = transformVertices(graph, vertexIdMap); Map<Integer, FSMEdge> fsmEdges = transformEdges(graph, vertexIdMap); return new CCSGraph( category, graph.getGraphHead().getId(), fsmVertices, fsmEdges); } }
@Test public void testGraphHead() { GradoopId graphId = GradoopId.get(); String label = "A"; Properties props = Properties.create(); props.set("k1", "v1"); props.set("k2", "v2"); EPGMGraphHead graphHead = new GraphHeadFactory().initGraphHead(graphId, label, props); String newLabel = "B"; TransformationFunction<EPGMGraphHead> renameFunction = new RenameLabel<>(label, newLabel); renameFunction.apply(graphHead, graphHead); assertEquals(newLabel, graphHead.getLabel()); assertThat(graphHead.getPropertyValue("k1").toString(), Is.<Object>is("v1")); assertThat(graphHead.getPropertyValue("k2").toString(), Is.<Object>is("v2")); }
@Test public void testVertex() { GradoopId vertexId = GradoopId.get(); String label = "A"; Properties props = Properties.create(); props.set("k1", "v1"); props.set("k2", "v2"); EPGMVertex vertex = new VertexFactory().initVertex(vertexId, label, props); String newLabel = "B"; TransformationFunction<EPGMVertex> renameFunction = new RenameLabel<>(label, newLabel); renameFunction.apply(vertex, vertex); assertEquals(newLabel, vertex.getLabel()); assertThat(vertex.getPropertyValue("k1").toString(), Is.<Object>is("v1")); assertThat(vertex.getPropertyValue("k2").toString(), Is.<Object>is("v2")); } }