/** * Returns a collection of all nodes of the graph. * @return all nodes of the graph */ public Collection<Node> getNodes() { Collection<Node> nodes = new ArrayList<Node>(); DynamicTable baseTable = graph.getVertexTable(); Table nodeTable = new IvtkObviousTable(baseTable); for (int i = 0; i < nodeTable.getRowCount(); i++) { nodes.add(new NodeImpl(nodeTable, i)); } return nodes; }
Node node = (Node) new NodeImpl(nodeSchema, nodeAttr); network.addNode(node);
@Override public Node addNode() { Object[] values = new Object[nodeSchema.getColumnCount()]; for (int i = 0; i < nodeSchema.getColumnCount(); i++) { values[i] = nodeSchema.getColumnDefault(i); } NodeImpl node = new NodeImpl(nodeSchema, values); network.addNode(node); return new WrapToPrefNode(network, node, getNodeCount()); }
/** * Returns an obvious node corresponding to a prefuse node. * @param node prefuse node * @return an obvious node */ private obvious.data.Node getObviousNode(Node node) { Object[] values = new Object[node.getSchema().getColumnCount()]; for (int i = 0; i < node.getSchema().getColumnCount(); i++) { values[i] = node.get(node.getSchema().getColumnName(i)); } return new NodeImpl(nodeSchema, values); }
/** * Loads the table with the data of external CSV files. * @return an obvious network * @throws ObviousxException when exception occurs */ public Network loadGraph() throws ObviousxException { CSVTableImport nodeImport = new CSVTableImport(nodeFile, new TableImpl(nodeSchema), separator); CSVTableImport edgeImport = new CSVTableImport(edgeFile, new TableImpl(edgeSchema), separator); Table nodeTable = nodeImport.loadTable(); Table edgeTable = edgeImport.loadTable(); for (int i = 0; i < nodeTable.getRowCount(); i++) { Node node = new NodeImpl(nodeTable, i); network.addNode(node); if (nodeId == null) { idToNode.put(node.getRow(), node); } else { idToNode.put(node.get(nodeId), node); } } for (int i = 0; i < edgeTable.getRowCount(); i++) { Edge edge = new EdgeImpl(edgeTable, i); network.addEdge(edge, idToNode.get(edge.get(sourceCol)), idToNode.get(edge.get(targetCol)), network.getEdgeType(edge)); } return this.network; }