GenericData.Array<GenericRecord> interEvalues = (GenericData.Array<GenericRecord>) value.get("interEdges"); for (GenericRecord valE: interEvalues) { interEdges.add(new GraphEdge((Long)valE.get("dstID"), (Double)valE.get("dstX"), (Double)valE.get("dstY"), GenericData.Array<GenericRecord> intraEvalues = (GenericData.Array<GenericRecord>) value.get("intraEdges"); for (GenericRecord valE: intraEvalues) { intraEdges.add(new GraphEdge((Long)valE.get("dstID"), (Double)valE.get("dstX"), (Double)valE.get("dstY"),
private List<GraphEdge> minOfEdgeLists(GraphEdge accumulatedMin, List<GraphEdge> newMin) { long dstID = accumulatedMin.getDstID(); double x = accumulatedMin.getDstCoords().getFirst(); double y = accumulatedMin.getDstCoords().getSecond(); long weight = accumulatedMin.getWeight(); for (int i = 0; i < newMin.size(); ++i) { dstID = Math.min(dstID, newMin.get(i).getDstID()); x = Math.min(x, newMin.get(i).getDstCoords().getFirst()); y = Math.min(y, newMin.get(i).getDstCoords().getSecond()); weight = Math.min(weight, newMin.get(i).getWeight()); } return Arrays.asList(new GraphEdge(dstID, x, y, weight)); }
private List<GraphEdge> maxOfEdgeLists(GraphEdge accumulatedMax, List<GraphEdge> newMax) { long dstID = accumulatedMax.getDstID(); double x = accumulatedMax.getDstCoords().getFirst(); double y = accumulatedMax.getDstCoords().getSecond(); long weight = accumulatedMax.getWeight(); for (int i = 0; i < newMax.size(); ++i) { dstID = Math.max(dstID, newMax.get(i).getDstID()); x = Math.max(x, newMax.get(i).getDstCoords().getFirst()); y = Math.max(y, newMax.get(i).getDstCoords().getSecond()); weight = Math.max(weight, newMax.get(i).getWeight()); } return Arrays.asList(new GraphEdge(dstID, x, y, weight)); }
@Test public void testInterEdgeToCommunity () { GraphCommunity a = _sampleCommunity; GraphEdge e1 = new GraphEdge(987L, 0.1, 0.2, 999L); GraphCommunity b = a; b.addInterEdgeToCommunity(e1); List<GraphEdge> edges = Arrays.asList(e1, new GraphEdge(0L, 4.3, 2.1, 5L), new GraphEdge(43L, 5.6, 7.8, 3L)); GraphCommunity c = new GraphCommunity(_hierLevel, _id, _coords, _radius, _degree, _numNodes, _metadata, _bIsPrimaryNode, _parentID, _parentCoords, _parentRadius, _statsList, edges, _intraEdges); Assert.assertEquals(c, b); }
@Test public void testIntraEdgeToCommunity () { GraphCommunity a = _sampleCommunity; GraphEdge e2 = new GraphEdge(988L, 0.11, 0.22, 1L); GraphCommunity b = a; b.addIntraEdgeToCommunity(e2); List<GraphEdge> edges = Arrays.asList(new GraphEdge(2L, 4.2, 2.0, 6L), new GraphEdge(44L, 5.5, 7.7, 4L), e2); GraphCommunity c = new GraphCommunity(_hierLevel, _id, _coords, _radius, _degree, _numNodes, _metadata, _bIsPrimaryNode, _parentID, _parentCoords, _parentRadius, _statsList, _interEdges, edges); Assert.assertEquals(c, b); }
List<GraphEdge> minEdgeList = Arrays.asList(new GraphEdge(Long.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE, Long.MAX_VALUE)); GraphCommunity minCommunity = new GraphCommunity(Integer.MAX_VALUE, Long.MAX_VALUE,
List<GraphEdge> maxEdgeList = Arrays.asList(new GraphEdge(Long.MIN_VALUE, Double.MIN_VALUE, Double.MIN_VALUE, Long.MIN_VALUE)); GraphCommunity maxCommunity = new GraphCommunity(Integer.MIN_VALUE, Long.MIN_VALUE,
10.1, Arrays.asList(99.0), Arrays.asList(new GraphEdge(1L, 4.3, 2.1, 5L)), Arrays.asList(new GraphEdge(1L, 4.3, 2.1, 5L))); GraphAnalyticsRecord b = new GraphAnalyticsRecord(1, Arrays.asList(community_b)); 10.1, Arrays.asList(-23.0), Arrays.asList(new GraphEdge(0L, 4.3, 2.1, 3L)), Arrays.asList(new GraphEdge(1L, 4.2, 2.0, 4L)));
10.1, Arrays.asList(-23.0), Arrays.asList(new GraphEdge(1L, 4.3, 2.1, 5L)), Arrays.asList(new GraphEdge(1L, 4.3, 2.1, 5L))); GraphAnalyticsRecord b = new GraphAnalyticsRecord(1, Arrays.asList(community_b)); 10.2, Arrays.asList(33.0), Arrays.asList(new GraphEdge(43L, 5.6, 7.8, 5L)), Arrays.asList(new GraphEdge(44L, 5.5, 7.7, 6L)));