org.gradoop.common.model.impl.pojo.Vertex.getLabel()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(9.5k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中org.gradoop.common.model.impl.pojo.Vertex.getLabel()方法的一些代码示例,展示了Vertex.getLabel()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Vertex.getLabel()方法的具体详情如下:
包路径:org.gradoop.common.model.impl.pojo.Vertex
类名称:Vertex
方法名:getLabel

Vertex.getLabel介绍

暂无

代码示例

代码示例来源:origin: org.gradoop/gradoop-flink

/**
 * Returns a mapping between the vertex GradoopID and the GDL variable name.
 *
 * @param vertices The graph vertices.
 * @return Mapping between vertex and GDL variable name.
 */
private Map<GradoopId, String> getVertexNameMapping(List<Vertex> vertices) {
 Map<GradoopId, String> idToVertexName = new HashMap<>(vertices.size());
 for (int i = 0; i < vertices.size(); i++) {
  Vertex v = vertices.get(i);
  String vName = String.format("%s_%s_%s", VERTEX_VARIABLE_PREFIX, v.getLabel(), i);
  idToVertexName.put(v.getId(), vName);
 }
 return idToVertexName;
}

代码示例来源:origin: dbs-leipzig/gradoop

/**
 * Returns a mapping between the vertex GradoopID and the GDL variable name.
 *
 * @param vertices The graph vertices.
 * @return Mapping between vertex and GDL variable name.
 */
private Map<GradoopId, String> getVertexNameMapping(List<Vertex> vertices) {
 Map<GradoopId, String> idToVertexName = new HashMap<>(vertices.size());
 for (int i = 0; i < vertices.size(); i++) {
  Vertex v = vertices.get(i);
  String vName = String.format("%s_%s_%s", VERTEX_VARIABLE_PREFIX, v.getLabel(), i);
  idToVertexName.put(v.getId(), vName);
 }
 return idToVertexName;
}

代码示例来源:origin: dbs-leipzig/gradoop

@Override
 public GraphTransaction map(GraphTransaction graphTransaction)
   throws Exception {
  String label;
  for (Vertex vertex : graphTransaction.getVertices()) {
   label = vertexDictionary.get(Integer.parseInt(vertex.getLabel()));
   if (label != null) {
    vertex.setLabel(label);
   } else {
    vertex.setLabel(vertex.getLabel() + TLFConstants.EMPTY_LABEL);
   }
  }
  return graphTransaction;
 }
}

代码示例来源:origin: dbs-leipzig/gradoop

@Override
 public void flatMap(GraphTransaction graphTransaction, Collector<String> collector)
  throws Exception {
  for (Vertex vertex : graphTransaction.getVertices()) {
   collector.collect(vertex.getLabel());
  }
 }
}

代码示例来源:origin: org.gradoop/gradoop-flink

@Override
 public void flatMap(GraphTransaction graphTransaction, Collector<String> collector)
  throws Exception {
  for (Vertex vertex : graphTransaction.getVertices()) {
   collector.collect(vertex.getLabel());
  }
 }
}

代码示例来源:origin: org.gradoop/gradoop-flink

@Override
 public void flatMap(GraphTransaction graph,
  Collector<WithCount<String>> out) throws Exception {

  Set<String> vertexLabels = Sets.newHashSet();

  for (Vertex vertex : graph.getVertices()) {
   vertexLabels.add(vertex.getLabel());
  }

  for (String label : vertexLabels) {
   reuseTuple.setObject(label);
   out.collect(reuseTuple);
  }
 }
}

代码示例来源:origin: dbs-leipzig/gradoop

@Override
 public void flatMap(GraphTransaction graph,
  Collector<WithCount<String>> out) throws Exception {

  Set<String> vertexLabels = Sets.newHashSet();

  for (Vertex vertex : graph.getVertices()) {
   vertexLabels.add(vertex.getLabel());
  }

  for (String label : vertexLabels) {
   reuseTuple.setObject(label);
   out.collect(reuseTuple);
  }
 }
}

代码示例来源:origin: org.gradoop/gradoop-flink

/**
 * Returns the gdl formatted vertex including the properties and the label on first occurrence
 * or otherwise just the variable name.
 *
 * @param v The vertex that should be formatted.
 * @param idToVertexName Maps GradoopId of a vertex to a string that represents the gdl
 *                       variable name
 * @return A GDL formatted vertex string.
 */
private String vertexToGDLString(Vertex v, Map<GradoopId, String> idToVertexName)  {
 return String.format("(%s:%s %s)",
  idToVertexName.get(v.getId()),
  v.getLabel(),
  propertiesToGDLString(v.getProperties()));
}

代码示例来源:origin: dbs-leipzig/gradoop

/**
 * Returns the gdl formatted vertex including the properties and the label on first occurrence
 * or otherwise just the variable name.
 *
 * @param v The vertex that should be formatted.
 * @param idToVertexName Maps GradoopId of a vertex to a string that represents the gdl
 *                       variable name
 * @return A GDL formatted vertex string.
 */
private String vertexToGDLString(Vertex v, Map<GradoopId, String> idToVertexName)  {
 return String.format("(%s:%s %s)",
  idToVertexName.get(v.getId()),
  v.getLabel(),
  propertiesToGDLString(v.getProperties()));
}

代码示例来源:origin: dbs-leipzig/gradoop

/**
 * The actual computation.
 *
 * @param socialNetwork social network graph
 * @return summarized, aggregated graph
 */
private static LogicalGraph execute(LogicalGraph socialNetwork) {
 return socialNetwork
  .subgraph(
   vertex -> vertex.getLabel().equals("Person"),
   edge -> edge.getLabel().equals("knows"))
  .groupBy(Arrays.asList("gender", "city"))
  .aggregate(new VertexCount(), new EdgeCount());
}

代码示例来源:origin: org.gradoop/gradoop-flink

@Override
 public LabeledGraphStringString map(GraphTransaction transaction) throws Exception {

  LabeledGraphStringString outGraph = LabeledGraphStringString.getEmptyOne();

  Map<String, Integer> labelMap = Maps.newHashMap();
  Map<GradoopId, Integer> vertexIdMap = Maps.newHashMap();

  for (Vertex vertex : transaction.getVertices()) {
   vertexIdMap.put(vertex.getId(), outGraph.addVertex(vertex.getLabel()));
  }

  labelMap.clear();

  for (Edge edge : transaction.getEdges()) {
   int sourceId = vertexIdMap.get(edge.getSourceId());
   int targetId = vertexIdMap.get(edge.getTargetId());
   outGraph.addEdge(sourceId, edge.getLabel(), targetId);
  }

  return outGraph;
 }
}

代码示例来源:origin: dbs-leipzig/gradoop

@Override
 public LabeledGraphStringString map(GraphTransaction transaction) throws Exception {

  LabeledGraphStringString outGraph = LabeledGraphStringString.getEmptyOne();

  Map<String, Integer> labelMap = Maps.newHashMap();
  Map<GradoopId, Integer> vertexIdMap = Maps.newHashMap();

  for (Vertex vertex : transaction.getVertices()) {
   vertexIdMap.put(vertex.getId(), outGraph.addVertex(vertex.getLabel()));
  }

  labelMap.clear();

  for (Edge edge : transaction.getEdges()) {
   int sourceId = vertexIdMap.get(edge.getSourceId());
   int targetId = vertexIdMap.get(edge.getTargetId());
   outGraph.addEdge(sourceId, edge.getLabel(), targetId);
  }

  return outGraph;
 }
}

代码示例来源:origin: dbs-leipzig/gradoop

static Vertex transformVertex(Vertex current, Vertex transformed) {
 transformed.setLabel(current.getLabel());
 if (current.getLabel().equals("A")) {
  transformed.setProperty("a", current.getPropertyValue("a").getInt() + 1);
  transformed.setProperty("b", current.getPropertyValue("b").getInt() - 1);
 } else if (current.getLabel().equals("B")) {
  transformed.setProperty("d", current.getPropertyValue("c"));
 }
 return transformed;
}

代码示例来源:origin: dbs-leipzig/gradoop

@Test
public void getVerticesByLabel() throws Exception {
 TxCollectionLayout layout = new TxCollectionLayout(
  getExecutionEnvironment().fromElements(tx0, tx1));
 GradoopTestUtils.validateEPGMGraphElementCollections(
  tx0.getVertices().stream().filter(v -> v.getLabel().equals("A")).collect(Collectors.toList()),
  layout.getVerticesByLabel("A").collect());
}

代码示例来源:origin: dbs-leipzig/gradoop

@Test
public void testVertexInducedSubgraph() throws Exception {
 FlinkAsciiGraphLoader loader = getSocialNetworkLoader();
 loader.appendToDatabaseFromString("expected[" +
  "(databases)<-[ghtd]-(gdbs)-[ghtg1]->(graphs)" +
  "(graphs)<-[ghtg2]-(gps)-[ghth]->(hadoop)" +
  "]");
 LogicalGraph input = loader.getLogicalGraph();
 LogicalGraph expected = loader.getLogicalGraphByVariable("expected");
 LogicalGraph output = input.vertexInducedSubgraph(
  v -> v.getLabel().equals("Forum") || v.getLabel().equals("Tag"));
 collectAndAssertTrue(output.equalsByElementData(expected));
}

代码示例来源:origin: org.gradoop/gradoop-flink

@Override
 public CSVVertex map(Vertex vertex) throws Exception {
  csvVertex.setId(vertex.getId().toString());
  csvVertex.setGradoopIds(collectionToCsvString(vertex.getGraphIds()));
  csvVertex.setLabel(StringEscaper.escape(vertex.getLabel(), CSVConstants.ESCAPED_CHARACTERS));
  csvVertex.setProperties(getPropertyString(vertex, MetaDataSource.VERTEX_TYPE));
  return csvVertex;
 }
}

代码示例来源:origin: dbs-leipzig/gradoop

@Override
 public CSVVertex map(Vertex vertex) throws Exception {
  csvVertex.setId(vertex.getId().toString());
  csvVertex.setGradoopIds(collectionToCsvString(vertex.getGraphIds()));
  csvVertex.setLabel(StringEscaper.escape(vertex.getLabel(), CSVConstants.ESCAPED_CHARACTERS));
  csvVertex.setProperties(getPropertyString(vertex, MetaDataSource.VERTEX_TYPE));
  return csvVertex;
 }
}

代码示例来源:origin: dbs-leipzig/gradoop

/**
 * Extracts a subgraph which is empty.
 *
 * @throws Exception
 */
@Test
public void testEmptySubgraph() throws Exception {
 FlinkAsciiGraphLoader loader = getSocialNetworkLoader();
 loader.appendToDatabaseFromString("expected[]");
 LogicalGraph input = loader.getLogicalGraph();
 LogicalGraph expected = loader.getLogicalGraphByVariable("expected");
 LogicalGraph output = input.subgraph(
  v -> v.getLabel().equals("User"),
  e -> e.getLabel().equals("friendOf"));
 collectAndAssertTrue(output.equalsByElementData(expected));
}

代码示例来源:origin: dbs-leipzig/gradoop

@Test
public void testGetVertices() throws Exception {
 AsciiGraphLoader<GraphHead, Vertex, Edge> asciiGraphLoader =
  AsciiGraphLoader.fromString("[()]", config);
 validateCollections(asciiGraphLoader, 1, 1, 0);
 validateCaches(asciiGraphLoader, 0, 0, 0);
 for (Vertex vertex : asciiGraphLoader.getVertices()) {
  assertEquals("Vertex has wrong label",
   GradoopConstants.DEFAULT_VERTEX_LABEL, vertex.getLabel());
 }
}

代码示例来源:origin: dbs-leipzig/gradoop

@Test
public void testGetVertexByVariable() {
 AsciiGraphLoader<GraphHead, Vertex, Edge> asciiGraphLoader =
  AsciiGraphLoader.fromString("(a)", config);
 validateCollections(asciiGraphLoader, 0, 1, 0);
 validateCaches(asciiGraphLoader, 0, 1, 0);
 Vertex v = asciiGraphLoader.getVertexByVariable("a");
 assertEquals("Vertex has wrong label",
  GradoopConstants.DEFAULT_VERTEX_LABEL, v.getLabel());
 assertNotNull("Vertex was null", v);
}

相关文章