コード例 #1
0
 private boolean isRanking(Graph graph, Column column) {
   if (column.isDynamic() && column.isNumber()) {
     ElementIterable<? extends Element> iterable =
         AttributeUtils.isNodeColumn(column) ? graph.getNodes() : graph.getEdges();
     for (Element el : iterable) {
       if (el.getAttribute(column, graph.getView()) != null) {
         iterable.doBreak();
         return true;
       }
     }
   } else if (!column.isDynamic() && column.isIndexed() && column.isNumber()) {
     Index index;
     if (AttributeUtils.isNodeColumn(column)) {
       index = localScale ? graphModel.getNodeIndex(graph.getView()) : graphModel.getNodeIndex();
     } else {
       index = localScale ? graphModel.getEdgeIndex(graph.getView()) : graphModel.getEdgeIndex();
     }
     if (index.countValues(column) > 0) {
       return true;
     }
   }
   return false;
 }
コード例 #2
0
 private boolean isPartition(Graph graph, Column column) {
   if (column.isDynamic()) {
     Set<Object> set = new HashSet<Object>();
     boolean hasNullValue = false;
     int elements = 0;
     ElementIterable<? extends Element> iterable =
         AttributeUtils.isNodeColumn(column) ? graph.getNodes() : graph.getEdges();
     for (Element el : iterable) {
       TimeMap val = (TimeMap) el.getAttribute(column);
       if (val != null) {
         Object[] va = val.toValuesArray();
         for (Object v : va) {
           if (v != null) {
             set.add(v);
           } else {
             hasNullValue = true;
           }
           elements++;
         }
       }
     }
     double ratio = set.size() / (double) elements;
     return ratio <= 0.9;
   } else if (column.isIndexed()) {
     Index index;
     if (AttributeUtils.isNodeColumn(column)) {
       index = graphModel.getNodeIndex(graph.getView());
     } else {
       index = graphModel.getEdgeIndex(graph.getView());
     }
     int valueCount = index.countValues(column);
     int elementCount = index.countElements(column);
     double ratio = valueCount / (double) elementCount;
     return ratio <= 0.9;
   }
   return false;
 }