public void testAddingRemovingEdgeProperties() { Graph graph = graphTest.generateGraph(); if (graph.getFeatures().supportsEdgeProperties) { Vertex a = graph.addVertex(convertId(graph, "1")); Vertex b = graph.addVertex(convertId(graph, "2")); Edge edge = graph.addEdge(convertId(graph, "3"), a, b, "knows"); assertEquals(edge.getPropertyKeys().size(), 0); assertNull(edge.getProperty("weight")); if (graph.getFeatures().supportsDoubleProperty) { edge.setProperty("weight", 0.5); assertEquals(edge.getPropertyKeys().size(), 1); assertEquals(edge.getProperty("weight"), 0.5); edge.setProperty("weight", 0.6); assertEquals(edge.getPropertyKeys().size(), 1); assertEquals(edge.getProperty("weight"), 0.6); assertEquals(edge.removeProperty("weight"), 0.6); assertNull(edge.getProperty("weight")); assertEquals(edge.getPropertyKeys().size(), 0); } if (graph.getFeatures().supportsStringProperty) { edge.setProperty("blah", "marko"); edge.setProperty("blah2", "josh"); assertEquals(edge.getPropertyKeys().size(), 2); } } graph.shutdown(); }
public void testAddingRemovingEdgeProperties() { if (!graphTest.isRDFModel) { Graph graph = graphTest.getGraphInstance(); Vertex a = graph.addVertex(convertId("1")); Vertex b = graph.addVertex(convertId("2")); Edge edge = graph.addEdge(convertId("3"), a, b, "knows"); assertEquals(edge.getPropertyKeys().size(), 0); assertNull(edge.getProperty("weight")); edge.setProperty("weight", 0.5); assertEquals(edge.getPropertyKeys().size(), 1); assertEquals(edge.getProperty("weight"), 0.5); edge.setProperty("weight", 0.6); assertEquals(edge.getPropertyKeys().size(), 1); assertEquals(edge.getProperty("weight"), 0.6); assertEquals(edge.removeProperty("weight"), 0.6); assertNull(edge.getProperty("weight")); assertEquals(edge.getPropertyKeys().size(), 0); edge.setProperty("blah", "marko"); edge.setProperty("blah2", "josh"); assertEquals(edge.getPropertyKeys().size(), 2); } }
public void testTinkerGraphEdges(Graph graph) throws Exception { if (config.supportsEdgeIteration) { this.stopWatch(); GraphMLReader.inputGraph( graph, GraphMLReader.class.getResourceAsStream("graph-example-1.xml")); BaseTest.printPerformance(graph.toString(), null, "graph-example-1 loaded", this.stopWatch()); Set<String> edgeIds = new HashSet<String>(); Set<String> edgeKeys = new HashSet<String>(); Set<String> edgeValues = new HashSet<String>(); int count = 0; for (Edge e : graph.getEdges()) { count++; edgeIds.add(e.getId().toString()); for (String key : e.getPropertyKeys()) { edgeKeys.add(key); edgeValues.add(e.getProperty(key).toString()); } } assertEquals(count, 6); assertEquals(edgeIds.size(), 6); assertEquals(edgeKeys.size(), 1); assertEquals(edgeValues.size(), 4); } }