当前位置: 首页>>代码示例>>Java>>正文


Java TinkerGraph.addEdge方法代码示例

本文整理汇总了Java中com.tinkerpop.blueprints.impls.tg.TinkerGraph.addEdge方法的典型用法代码示例。如果您正苦于以下问题:Java TinkerGraph.addEdge方法的具体用法?Java TinkerGraph.addEdge怎么用?Java TinkerGraph.addEdge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.tinkerpop.blueprints.impls.tg.TinkerGraph的用法示例。


在下文中一共展示了TinkerGraph.addEdge方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import com.tinkerpop.blueprints.impls.tg.TinkerGraph; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
  graph = new TinkerGraph();

  Vertex S0 = graph.addVertex( "S0" );
  Vertex S1 = graph.addVertex( "S1" );
  Vertex a = graph.addVertex( "A" );
  Vertex b = graph.addVertex( "B" );
  Vertex c = graph.addVertex( "C" );
  Vertex d = graph.addVertex( "D" );

  graph.addEdge( null, S0, a, GraphUtils.EDGE_HOPSTO );
  graph.addEdge( null, S1, b, GraphUtils.EDGE_HOPSTO );
  graph.addEdge( null, a, b, GraphUtils.EDGE_HOPSTO );
  graph.addEdge( null, b, c, GraphUtils.EDGE_HOPSTO );
  graph.addEdge( null, b, d, GraphUtils.EDGE_HOPSTO );

  // Expect layout
  // S0 -> A -> B -> C
  // S1 -------^ `-> D

  horizontalLayout = new HorizontalLayout();
}
 
开发者ID:mattyb149,项目名称:pdi-layout,代码行数:24,代码来源:HorizontalLayoutTest.java

示例2: transform

import com.tinkerpop.blueprints.impls.tg.TinkerGraph; //导入方法依赖的package包/类
public static void transform(NerdleFact fact, TinkerGraph graph) {
	Vertex predicate = createPredicateVertex(fact.getPredicate(),
			fact.getSentence(), fact.getSource(), fact.getConfidence(),
			graph);
	Vertex subject = createSubjectVertex(fact.getSubject(), graph);
	graph.addEdge(null, predicate, subject, "hasSubject");

	for (NerdleArg nerdleArg : fact.getArguments()) {
		Vertex argument = createArgumentVertex(nerdleArg, graph);
		graph.addEdge(null, predicate, argument, "hasArgument");
	}
}
 
开发者ID:impro3-nerdle,项目名称:nerdle,代码行数:13,代码来源:NerdleGraphTransformer.java

示例3: createPredicateVertex

import com.tinkerpop.blueprints.impls.tg.TinkerGraph; //导入方法依赖的package包/类
private static Vertex createPredicateVertex(
		NerdlePredicate nerdlePredicate, String sentence, String source,
		double confidence, TinkerGraph graph) {

	Vertex vertex = graph.addVertex(null);
	vertex.setProperty(PROPERTY_VERBTEXT, nerdlePredicate.getText());
	String lemma = nerdlePredicate.getLemma();
	if(lemma == null || lemma.isEmpty()){
		vertex.setProperty(PROPERTY_LEMMA, nerdlePredicate.getText());
	} else {
		vertex.setProperty(PROPERTY_LEMMA, lemma);
	}
	vertex.setProperty(PROPERTY_ISSYNONYM, false);
	vertex.setProperty(PROPERTY_CLAUSE_TYPE, VALUE_CLAUSE_TYPE_PREDICATE);
	vertex.setProperty(PROPERTY_SENTENCE, sentence);
	vertex.setProperty(PROPERTY_SOURCE, source);
	vertex.setProperty(PROPERTY_CONFIDENCE, confidence);
	for (String synonym : nerdlePredicate.getSynonyms()) {
		Vertex synonymVertex = graph.addVertex(null);
		synonymVertex.setProperty(PROPERTY_LEMMA, synonym);
		synonymVertex.setProperty(PROPERTY_CLAUSE_TYPE,
				VALUE_CLAUSE_TYPE_PREDICATE);
		synonymVertex.setProperty(PROPERTY_ISSYNONYM, true);
		graph.addEdge(null, vertex, synonymVertex, "hasSynonym");
	}
	return vertex;
}
 
开发者ID:impro3-nerdle,项目名称:nerdle,代码行数:28,代码来源:NerdleGraphTransformer.java

示例4: testAPI

import com.tinkerpop.blueprints.impls.tg.TinkerGraph; //导入方法依赖的package包/类
@Test
public void testAPI() throws Exception {
	TinkerGraph graph = new TinkerGraph();
	Vertex a = graph.addVertex(null);
	Vertex b = graph.addVertex(null);
	a.setProperty("name","marko");
	b.setProperty("name","peter");
	Edge e = graph.addEdge(null, a, b, "knows");
	e.setProperty("since", 2006);
}
 
开发者ID:impro3-nerdle,项目名称:nerdle,代码行数:11,代码来源:BluesprintsTest.java

示例5: graphsAreMerged

import com.tinkerpop.blueprints.impls.tg.TinkerGraph; //导入方法依赖的package包/类
@Test
public void graphsAreMerged() {
  TinkerGraph graph1 = new TinkerGraph();
  Vertex g1v1 = graph1.addVertex(0);
  Vertex g1v2 = graph1.addVertex(1);
  Edge g1e1 = graph1.addEdge(0, g1v1, g1v2, "test");
  TinkerGraph graph2 = new TinkerGraph();
  Vertex g2v1 = graph2.addVertex(1);
  Vertex g2v2 = graph2.addVertex(2);
  Edge g2e1 = graph1.addEdge(1, g2v1, g2v2, "test2");
  TinkerGraphUtil tgu = new TinkerGraphUtil(graph1, curieUtil);
  Graph graph = tgu.combineGraphs(graph2);
  assertThat(graph.getVertices(), containsInAnyOrder(g1v1, g1v2, g2v2));
  assertThat(graph.getEdges(), containsInAnyOrder(g1e1, g2e1));
}
 
开发者ID:SciGraph,项目名称:SciGraph,代码行数:16,代码来源:TinkerGraphUtilTest.java

示例6: setup

import com.tinkerpop.blueprints.impls.tg.TinkerGraph; //导入方法依赖的package包/类
@Before
public void setup() {
  TinkerGraph graph = new TinkerGraph();
  v1 = graph.addVertex(0);
  v2 = graph.addVertex(1);
  v1.setProperty(CommonProperties.IRI, "foo");
  v1.setProperty("foo", "bar");
  e = graph.addEdge(0, v1, v2, "test");
  e.setProperty("foo", 1);
  ArrayPropertyTransformer.transform(graph);
}
 
开发者ID:SciGraph,项目名称:SciGraph,代码行数:12,代码来源:ArrayPropertyTransformerTest.java

示例7: testMultipleClauses

import com.tinkerpop.blueprints.impls.tg.TinkerGraph; //导入方法依赖的package包/类
@Test
public void testMultipleClauses() throws Exception {
	TinkerGraph graph = new TinkerGraph();
	graph.createIndex("verb-idx", Vertex.class);
	
	Vertex a = graph.addVertex(null);
	Vertex b = graph.addVertex(null);
	Vertex c = graph.addVertex(null);
	Vertex d = graph.addVertex(null);
	
	a.setProperty(NerdleGraphTransformer.PROPERTY_TEXT,"Einstein");
	a.setProperty("ner", "PERSON");
	a.setProperty("clause_type", NerdleGraphTransformer.VALUE_CLAUSE_TYPE_SUBJECT);
	
	b.setProperty(NerdleGraphTransformer.PROPERTY_TEXT,"in Ulm");
	b.setProperty("ner", "PERSON");
	b.setProperty("clause_type", NerdleGraphTransformer.VALUE_CLAUSE_TYPE_ARGUMENT);
	
	c.setProperty(NerdleGraphTransformer.PROPERTY_TEXT,"on 4th May");
	c.setProperty("ner", "PERSON");
	c.setProperty("clause_type", NerdleGraphTransformer.VALUE_CLAUSE_TYPE_ARGUMENT);
	
	d.setProperty(NerdleGraphTransformer.PROPERTY_TEXT,"was born");
	d.setProperty("clause_type", NerdleGraphTransformer.VALUE_CLAUSE_TYPE_PREDICATE);
	
	graph.addEdge(null, d, a, "");
	graph.addEdge(null, d, b, "");
	graph.addEdge(null, d, c, "");
	
	Vertex aX = graph.addVertex(null);
	Vertex bX = graph.addVertex(null);
	Vertex cX = graph.addVertex(null);
	Vertex dX = graph.addVertex(null);
	
	aX.setProperty(NerdleGraphTransformer.PROPERTY_TEXT,"Einstein X");
	aX.setProperty("ner", "PERSON");
	aX.setProperty("clause_type", NerdleGraphTransformer.VALUE_CLAUSE_TYPE_SUBJECT);
	
	bX.setProperty(NerdleGraphTransformer.PROPERTY_TEXT,"in Ulm X");
	bX.setProperty("ner", "PERSON");
	bX.setProperty("clause_type", NerdleGraphTransformer.VALUE_CLAUSE_TYPE_ARGUMENT);
	
	cX.setProperty(NerdleGraphTransformer.PROPERTY_TEXT,"on 4th May");
	cX.setProperty("ner", "PERSON X");
	cX.setProperty("clause_type", NerdleGraphTransformer.VALUE_CLAUSE_TYPE_ARGUMENT);
	
	dX.setProperty(NerdleGraphTransformer.PROPERTY_TEXT,"was born X");
	dX.setProperty("clause_type", NerdleGraphTransformer.VALUE_CLAUSE_TYPE_PREDICATE);
	
	graph.addEdge(null, dX, aX, "");
	graph.addEdge(null, dX, bX, "");
	graph.addEdge(null, dX, cX, "");
}
 
开发者ID:impro3-nerdle,项目名称:nerdle,代码行数:54,代码来源:BluesprintsTest.java

示例8: buildGraph

import com.tinkerpop.blueprints.impls.tg.TinkerGraph; //导入方法依赖的package包/类
public static Graph buildGraph() {
	TinkerGraph graph = new TinkerGraph("/tmp/cfggraph", TinkerGraph.FileType.GRAPHML); 
	graph.createIndex("signatureName", Vertex.class);
	graph.createIndex("sha256", Vertex.class);
	graph.createIndex("md5", Vertex.class);
	graph.createIndex("type", Vertex.class);

	Map sigLookup = new HashMap<String, Vertex>();
	Map fileLookup = new HashMap<String, Vertex>();
	
	for(Match match : matches) {
		// check map for sig
		CFGSig matchSig = match.getSignature();
		String sigString = matchSig.getStringSignature();
		Vertex sigVertex = (Vertex)sigLookup.get(sigString);

		if(sigVertex == null) {
			// create vertex
			sigVertex = graph.addVertex(null);
			sigVertex.setProperty("type", "signature");
			sigVertex.setProperty("signature", sigString);
			sigVertex.setProperty("signatureName", matchSig.getName());
			// add sig to map
			sigLookup.put(sigString, sigVertex);
		}

		// check map for file
		String fileSHA256 = match.getFileSHA256();
		Vertex fileVertex = (Vertex)fileLookup.get(fileSHA256);

		if(fileVertex == null) {
			// create vertex
			fileVertex = graph.addVertex(null);
			sigVertex.setProperty("type", "file");
			fileVertex.setProperty("sha256", fileSHA256);
			fileVertex.setProperty("md5", match.getFileMD5());
			fileVertex.setProperty("fileNameList", new ArrayList<String>());
			// add file to map
			fileLookup.put(fileSHA256, fileVertex);
		}

		// what idiot would scan the same file multiple times with different names?
		List<String> fileNames = fileVertex.getProperty("fileNameList");
		if(!fileNames.contains(match.getFileName())) {
			fileNames.add(match.getFileName());
		}

		// TODO: comment this out and see if it still works
		fileVertex.setProperty("fileNameList", fileNames);

		// create edge(sig, file)
		Edge matchEdge = graph.addEdge(null, sigVertex, fileVertex, "matches");

		ControlFlowGraph cfg = match.getControlFlowGraph();
		matchEdge.setProperty("method", cfg.getIdentifier(false));
		// matchEdge.setProperty("fileBytes", cfg.getMethodBytesAsHexString());
	}

	return graph;
}
 
开发者ID:douggard,项目名称:CFGScanDroid,代码行数:61,代码来源:CFGScanDroid.java


注:本文中的com.tinkerpop.blueprints.impls.tg.TinkerGraph.addEdge方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。