EdgeImpl extends ElementImpl implements Edge { @Override public double getWeight() { synchronized (this) { Object weightObject = attributes[GraphStoreConfiguration.EDGE_WEIGHT_INDEX]; if (weightObject instanceof Double) { return (Double) weightObject; } else { return getWeight(graphStore.getView()); } } } EdgeImpl(Object id, GraphStore graphStore, NodeImpl source, NodeImpl target, int type, double weight, boolean directed);  EdgeImpl(Object id, NodeImpl source, NodeImpl target, int type, double weight, boolean directed); @Override NodeImpl getSource(); @Override NodeImpl getTarget(); @Override double getWeight(); @Override boolean hasDynamicWeight(); @Override void setWeight(double weight, double timestamp); @Override void setWeight(double weight, Interval interval); @Override double getWeight(double timestamp); @Override double getWeight(Interval interval); @Override double getWeight(GraphView view); @Override Iterable<Map.Entry> getWeights(); @Override int getType(); @Override Object getTypeLabel(); @Override void setWeight(double weight); int getNextOutEdge(); int getNextInEdge(); int getPreviousOutEdge(); int getPreviousInEdge(); @Override int getStoreId(); void setStoreId(int id); long getLongId(); @Override boolean isDirected(); @Override boolean isSelfLoop(); @Override Table getTable(); @Override float r(); @Override float g(); @Override float b(); @Override float alpha(); @Override TextPropertiesImpl getTextProperties(); @Override int getRGBA(); @Override Color getColor(); @Override void setR(float r); @Override void setG(float g); @Override void setB(float b); @Override void setAlpha(float a); @Override void setColor(Color color);  }
@Test public void testGetDefaultTimestampWeightWhenNotSet() { Configuration config = new Configuration(); config.setEdgeWeightType(TimestampDoubleMap.class); GraphStore graphStore = GraphGenerator.generateTinyGraphStore(config); Edge e = graphStore.getEdge("0"); Assert.assertEquals(e.getWeight(2.0), GraphStoreConfiguration.DEFAULT_DYNAMIC_EDGE_WEIGHT_WHEN_MISSING); }
@Test public void testGetDefaultIntervalWeightWhenNotSet() { Configuration config = new Configuration(); config.setTimeRepresentation(TimeRepresentation.INTERVAL); config.setEdgeWeightType(IntervalDoubleMap.class); GraphStore graphStore = GraphGenerator.generateTinyGraphStore(config); Edge e = graphStore.getEdge("0"); Assert.assertEquals(e.getWeight(new Interval(2.0, 4.0)), GraphStoreConfiguration.DEFAULT_DYNAMIC_EDGE_WEIGHT_WHEN_MISSING); }
@Test(expectedExceptions = IllegalStateException.class) public void testGetWeightTimestampError() { GraphStore graphStore = GraphGenerator.generateTinyGraphStore(); Edge e = graphStore.getEdge("0"); e.getWeight(1.0); }
@Test(expectedExceptions = IllegalStateException.class) public void testGetWeightIntervalError() { GraphStore graphStore = GraphGenerator.generateTinyGraphStore(TimeRepresentation.INTERVAL); Edge e = graphStore.getEdge("0"); e.getWeight(new Interval(1.0, 2.0)); }
@Test public void testGetDefaultWeightByGraphView() { Configuration config = new Configuration(); config.setEdgeWeightType(TimestampDoubleMap.class); GraphStore graphStore = GraphGenerator.generateTinyGraphStore(config); Edge e = graphStore.getEdge("0"); Assert.assertEquals(e.getWeight(graphStore.mainGraphView), GraphStoreConfiguration.DEFAULT_DYNAMIC_EDGE_WEIGHT_WHEN_MISSING); }
@Test public void testGetWeightNoValue() { Configuration config = new Configuration(); config.setEdgeWeightType(TimestampDoubleMap.class); GraphStore graphStore = GraphGenerator.generateTinyGraphStore(config); Edge e = graphStore.getEdge("0"); e.setAttribute("weight", null); Assert.assertEquals(e.getWeight(graphStore.getView()), GraphStoreConfiguration.DEFAULT_DYNAMIC_EDGE_WEIGHT_WHEN_MISSING); }
@Test public void testSetAttributeWeightTimestamp() { Configuration config = new Configuration(); config.setEdgeWeightType(TimestampDoubleMap.class); GraphStore graphStore = GraphGenerator.generateTinyGraphStore(config); Edge e = graphStore.getEdge("0"); Column col = graphStore.edgeTable.getColumn(GraphStoreConfiguration.EDGE_WEIGHT_INDEX); TimestampDoubleMap wm = new TimestampDoubleMap(); wm.put(1.0, 10.0); wm.put(2.0, 20.0); e.setAttribute(col, wm); Assert.assertEquals(e.getWeight(1.0), 10.0); Assert.assertEquals(e.getWeight(2.0), 20.0); }