private List<String> getAttributeList(
      CyNetwork network,
      Set<Class<?>> allowedNodeAttributeTypes,
      Set<Class<?>> allowedEdgeAttributeTypes) {
    List<String> attributes = new ArrayList<String>();
    Set<Class<?>> allowedTypes;
    CyTable table;
    if (allowedNodeAttributeTypes.size() > 0) {
      allowedTypes = allowedNodeAttributeTypes;
      table = network.getDefaultNodeTable();
    } else if (allowedEdgeAttributeTypes.size() > 0) {
      allowedTypes = allowedEdgeAttributeTypes;
      table = network.getDefaultEdgeTable();
    } else {
      return attributes;
    }

    for (final CyColumn column : table.getColumns()) {
      if (allowedTypes.contains(column.getType())) {
        attributes.add(column.getName());
      }
    }

    if (attributes.size() > 0) attributes.add(0, UNWEIGHTED);
    return attributes;
  }
Beispiel #2
0
  private void initVariables() {
    edgeAttributes = context.getSelectedEdgeAttributes();

    graph = new DirectedSparseMultigraph<>();
    idToNode = new HashMap<>();
    nodeList = network.getNodeList();
    edgeList = network.getEdgeList();
    nodeTable = network.getDefaultNodeTable();
    edgeTable = network.getDefaultEdgeTable();
  }
  private Collection<String> getAttributes(boolean node) {
    CyNetwork network = applicationManager.getCurrentNetwork();
    CyTable table = node ? network.getDefaultNodeTable() : network.getDefaultEdgeTable();
    Collection<CyColumn> columns = table.getColumns();

    Set<String> attributes =
        new TreeSet<String>(
            new Comparator<String>() {
              public int compare(String s1, String s2) {
                return s1.compareToIgnoreCase(s2);
              }
            });

    for (CyColumn column : columns) {
      if (!CyIdentifiable.SUID.equals(column.getName())
          && (node || Number.class.isAssignableFrom(column.getType()))) {
        attributes.add(column.getName());
      }
    }
    return attributes;
  }
 private List<String> getSupportedEdgeAttributes() {
   Set<Class<?>> supportedEdgeTypes = algorithm.getSupportedEdgeAttributeTypes();
   if (supportedEdgeTypes == null || supportedEdgeTypes.size() == 0) return null;
   return getSupportedAttributes(supportedEdgeTypes, network.getDefaultEdgeTable());
 }