本文整理汇总了Java中org.neo4j.graphdb.Relationship.getProperty方法的典型用法代码示例。如果您正苦于以下问题:Java Relationship.getProperty方法的具体用法?Java Relationship.getProperty怎么用?Java Relationship.getProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.neo4j.graphdb.Relationship
的用法示例。
在下文中一共展示了Relationship.getProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shuldCreateRelation
import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
@Test
public void shuldCreateRelation() {
context.setDocumentKey("key");
Node parent = db.createNode();
parent.setProperty("type", "album");
Node child = db.createNode();
child.setProperty("type", "artist");
Relationship rel = this.docrel.buildRelation(parent, child, context);
Assert.assertEquals(parent.getId(), rel.getStartNode().getId());
Assert.assertEquals(child.getId(), rel.getEndNode().getId());
Assert.assertEquals("HAS_ARTIST", rel.getType().name());
String[] keys = (String[]) rel.getProperty("docKeys");
Assert.assertEquals(1, keys.length);
Assert.assertEquals("key", keys[0]);
}
示例2: shuldCreateRelation
import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
@Test
public void shuldCreateRelation() {
context.setDocumentKey("key");
Node parent = db.createNode();
parent.setProperty("type", "album");
Node child = db.createNode();
child.setProperty("type", "artist");
Relationship rel = this.docrel.buildRelation(parent, child, context);
Assert.assertEquals(parent.getId(), rel.getStartNode().getId());
Assert.assertEquals(child.getId(), rel.getEndNode().getId());
Assert.assertEquals("album_artist", rel.getType().name());
String[] keys = (String[]) rel.getProperty("docKeys");
Assert.assertEquals(1, keys.length);
Assert.assertEquals("key", keys[0]);
}
示例3: shuldUpdateRelation
import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
@Test
public void shuldUpdateRelation() {
context.setDocumentKey("key1");
Node parent = db.createNode();
parent.setProperty("type", "album");
Node child = db.createNode();
child.setProperty("type", "artist");
Relationship rel1 = this.docrel.buildRelation(parent, child, context);
context.setDocumentKey("key2");
Relationship rel2 = this.docrel.buildRelation(parent, child, context);
Assert.assertEquals(rel1.getId(), rel2.getId());
String[] keys = (String[]) rel2.getProperty("docKeys");
Assert.assertEquals(2, keys.length);
Assert.assertEquals("key1", keys[0]);
Assert.assertEquals("key2", keys[1]);
}
示例4: shuldDoNothing
import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
@Test
public void shuldDoNothing() {
context.setDocumentKey("key");
Node parent = db.createNode();
parent.setProperty("type", "album");
Node child = db.createNode();
child.setProperty("type", "artist");
Relationship rel1 = this.docrel.buildRelation(parent, child, context);
Relationship rel2 = this.docrel.buildRelation(parent, child, context);
Assert.assertEquals(rel1.getId(), rel2.getId());
String[] keys = (String[]) rel2.getProperty("docKeys");
Assert.assertEquals(1, keys.length);
Assert.assertEquals("key", keys[0]);
}
示例5: getEdge
import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
@Override
public Edge getEdge(long id1, long id2) {
Edge edge = null;
try {
beginTransaction();
Relationship rel = getInnerRelationship(id1, id2);
if (rel != null) {
Vertex v1 = getVertex(id1);
Vertex v2 = getVertex(id2);
int weigth = 0;
if (rel.hasProperty(NetworkNeo4jProperties.WEIGHT)) {
weigth = (int) rel.getProperty(NetworkNeo4jProperties.WEIGHT);
}
long id = (long) rel.getProperty(NetworkNeo4jProperties.INDEX);
edge = new Edge(id, weigth, v1, v2);
}
} finally {
endTransaction();
}
return edge;
}
示例6: getAllEdges
import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
@Override
public Iterable<Edge> getAllEdges() {
List<Edge> list = new ArrayList<>();
try {
beginTransaction();
Result result = graphDb.execute("MATCH (a:NODE)-[r:LINK]->(b:NODE) RETURN r ORDER BY r.INDEX");
while (result.hasNext()) {
Map<String, Object> row = result.next();
Relationship rel = (Relationship) row.get("r");
Vertex v1 = getVertex((long) rel.getStartNode().getProperty(NetworkNeo4jProperties.INDEX));
Vertex v2 = getVertex((long) rel.getEndNode().getProperty(NetworkNeo4jProperties.INDEX));
Edge edge = new Edge((long) rel.getProperty(NetworkNeo4jProperties.INDEX),
(int) rel.getProperty(NetworkNeo4jProperties.WEIGHT),
v1,
v2);
list.add(edge);
}
} finally {
endTransaction();
}
return new EdgeIterable<Edge>(list.iterator(), new Edge());
}
示例7: getAllEdgesSortedByWight
import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
@Override
public Iterable<Edge> getAllEdgesSortedByWight() {
List<Edge> list = new ArrayList<>();
try {
beginTransaction();
Result result = graphDb.execute("MATCH (a:NODE)-[r:LINK]->(b:NODE) RETURN r ORDER BY r.WIGHT ASC");
while (result.hasNext()) {
Map<String, Object> row = result.next();
Relationship rel = (Relationship) row.get("r");
Vertex v1 = getVertex((long) rel.getStartNode().getProperty(NetworkNeo4jProperties.INDEX));
Vertex v2 = getVertex((long) rel.getEndNode().getProperty(NetworkNeo4jProperties.INDEX));
Edge edge = new Edge((long) rel.getProperty(NetworkNeo4jProperties.INDEX),
(int) rel.getProperty(NetworkNeo4jProperties.WEIGHT),
v1,
v2);
list.add(edge);
}
} finally {
endTransaction();
}
return new EdgeIterable<Edge>(list.iterator(), new Edge());
}
示例8: getAllEdgesSortedByWightDesc
import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
@Override
public Iterable<Edge> getAllEdgesSortedByWightDesc() {
List<Edge> list = new ArrayList<>();
try {
beginTransaction();
Result result = graphDb.execute("MATCH (a:NODE)-[r:LINK]->(b:NODE) RETURN r ORDER BY r.WIGHT DESC");
while (result.hasNext()) {
Map<String, Object> row = result.next();
Relationship rel = (Relationship) row.get("r");
Vertex v1 = getVertex((long) rel.getStartNode().getProperty(NetworkNeo4jProperties.INDEX));
Vertex v2 = getVertex((long) rel.getEndNode().getProperty(NetworkNeo4jProperties.INDEX));
Edge edge = new Edge((long) rel.getProperty(NetworkNeo4jProperties.INDEX),
(int) rel.getProperty(NetworkNeo4jProperties.WEIGHT),
v1,
v2);
list.add(edge);
}
} finally {
endTransaction();
}
return new EdgeIterable<Edge>(list.iterator(), new Edge());
}
示例9: traverse
import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
public void traverse() {
if (null != graph && null != root) {
try (Transaction tx = graph.beginTx()) {
PathFinder<Path> finder = GraphAlgoFactory.allPaths(
PathExpanders.forTypesAndDirections(RelTypes.CHILD_HI, Direction.OUTGOING, RelTypes.CHILD_LO, Direction.OUTGOING), 5);
// 5 is the number of original relationships + 1
Iterable<Path> paths = finder.findAllPaths(root, one);
double total = 0.0;
for (Path path : paths) {
double current = 1.0;
for (Relationship relationship : path.relationships()) {
current *= (double) relationship.getProperty(PROB, 1.0);
}
total += current;
}
System.out.format("The probability is %.2f.\n", total);
tx.success();
}
}
}
示例10: traverse
import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
public double traverse() {
if (null != root && value < 0.0) {
try (Transaction ignore = graph.beginTx()) {
value = 0.0;
PathFinder<Path> finder = GraphAlgoFactory.allPaths(
PathExpanders.forTypesAndDirections(RelType.LO_CHILD, Direction.OUTGOING, RelType.HI_CHILD, Direction.OUTGOING), max);
Iterable<Path> paths = finder.findAllPaths(root, one);
for (Path path : paths) {
double current = 1.0;
for (Relationship relationship : path.relationships()) {
current *= (double) relationship.getProperty(PROB, 1.0);
}
value += current;
}
}
}
return value;
}
示例11: removeOldEdges
import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
private void removeOldEdges(DDGDifference diff)
{
List<DefUseRelation> relsToRemove = diff.getRelsToRemove();
for (DefUseRelation rel : relsToRemove)
{
Node srcStatement = Neo4JDBInterface.getNodeById((Long) rel.src);
Iterable<Relationship> rels = srcStatement
.getRelationships(Direction.OUTGOING);
for (Relationship reachRel : rels)
{
if (!reachRel.getType().name().equals(EdgeTypes.REACHES))
continue;
if (reachRel.getEndNode().getId() != (Long) rel.dst)
continue;
Object var = reachRel.getProperty("var");
if (var == null || !var.toString().equals(rel.symbol))
continue;
Neo4JDBInterface.removeEdge(reachRel.getId());
}
}
}
示例12: ForeignKey
import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
public ForeignKey(Relationship relationship) {
constraintName = (String) relationship.getProperty("constraint");
sourceTableId = relationship.getStartNodeId();
destinationTableId = relationship.getEndNodeId();
sourceColumnName = (String) relationship.getProperty("source_column");
destinationColumnName = (String) relationship.getProperty("destination_column");
}
示例13: shouldDeleteOnlyKey
import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
@Test
public void shouldDeleteOnlyKey()
{
context.setDocumentKey("key");
Node parent = db.createNode();
parent.setProperty("type", "album");
Node child = db.createNode();
child.setProperty("type", "artist");
Node track = db.createNode();
track.setProperty("type", "track");
this.docrel.buildRelation(parent, child, context);
this.docrel.buildRelation(child, track, context);
context.setDocumentKey("another_key");
Relationship rel = this.docrel.buildRelation(child, track, context);
Set<Node> orphans = this.docrel.deleteRelations(context);
Assert.assertEquals(0, orphans.size());
Assert.assertEquals(1, StreamSupport.stream(parent.getRelationships().spliterator(), false).count());
Assert.assertEquals(1, StreamSupport.stream(child.getRelationships(Direction.OUTGOING).spliterator(), false).count());
String[] keys = (String[]) rel.getProperty("docKeys");
Assert.assertEquals(1, keys.length);
Assert.assertEquals("key", keys[0]);
}
示例14: convertRelationshipToEdge
import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
public static AbstractEdge convertRelationshipToEdge(Relationship relationship)
{
AbstractEdge resultEdge = new Edge(convertNodeToVertex(relationship.getStartNode()),
convertNodeToVertex(relationship.getEndNode()));
for (String key : relationship.getPropertyKeys())
{
String value = (String) relationship.getProperty(key);
if(StringUtils.isNullOrEmpty(value))
{
resultEdge.addAnnotation(key, value);
}
}
return resultEdge;
}
示例15: compute
import org.neo4j.graphdb.Relationship; //导入方法依赖的package包/类
@Override
public void compute(Relationship r) {
Node n1 = r.getStartNode();
Node n2 = r.getEndNode();
if( n1.getProperty(attName) == n2.getProperty(attName) ) {
double weight = r.hasProperty("weight") ? (double) r.getProperty("weight") : 1.0;
eii += weight;
}
}