/** * Internal method for clearing the edge table, removing all edges. */ protected void clearEdges() { getEdgeTable().clear(); }
/** * Get an iterator over all edge ids (edge table row numbers). * @return an iterator over all edge ids (edge table row numbers) */ public IntIterator edgeRows() { return getEdgeTable().rows(); }
/** * Get the number of edges in this graph. * @return the number of edges */ public int getEdgeCount() { return getEdgeTable().getRowCount(); }
/** * Gets an obvious Table containing the edges of this Network instance. * @return an obvious Table containing the edges of this Network instance */ public Table getEdgeTable() { return new PrefuseObviousTable(graph.getEdgeTable()); }
/** * Remove an edge from the graph. * @param edge the edge id (edge table row number) of the edge to remove * @return true if the edge was successfully removed, false if the * edge was not found or was not valid */ public boolean removeEdge(int edge) { return getEdgeTable().removeRow(edge); }
/** * Get the source node id (node table row number) for the given edge * id (edge table row number). * @param edge an edge id (edge table row number) * @return the source node id (node table row number) */ public int getSourceNode(int edge) { return getNodeIndex(getEdgeTable().getLong(edge, m_skey)); }
/** * Get the target node id (node table row number) for the given edge * id (edge table row number). * @param edge an edge id (edge table row number) * @return the target node id (node table row number) */ public int getTargetNode(int edge) { return getNodeIndex(getEdgeTable().getLong(edge, m_tkey)); }
/** * Dispose of this graph. Unregisters this graph as a listener to its * included tables. */ public void dispose() { getNodeTable().removeTableListener(m_listener); getEdgeTable().removeTableListener(m_listener); }
/* package */ GraphBuilder() { graph = new Graph( true ); Table nodeTable = graph.getNodeTable(); nodeTable.addColumn( GraphDisplay.NAME_LABEL, String.class ); nodeTable.addColumn( GraphDisplay.USER_OBJECT, Object.class ); Table edgeTable = graph.getEdgeTable(); edgeTable.addColumn( GraphDisplay.USES_EDGES, boolean.class, false ); childList = new ArrayList(); }
/** * Updates this graph to use a different edge structure for the same nodes. * All other settings will remain the same (e.g., directionality, keys) * @param edges the new edge table. */ public void setEdgeTable(Table edges) { Table oldEdges = getEdgeTable(); oldEdges.removeTableListener(m_listener); m_edgeTuples.invalidateAll(); m_links.clear(); init(getNodeTable(), edges, m_directed, m_nkey, m_skey, m_tkey); }
/** * Initialize the link table, which holds adjacency lists for this graph. */ protected void initLinkTable() { // set up cache of node data m_links = createLinkTable(); IntIterator edges = getEdgeTable().rows(); while ( edges.hasNext() ) { updateDegrees(edges.nextInt(), 1); } }
/** * Internal method for updating the linkage of this graph. * @param e the edge id for the updated link * @param incr the increment value, 1 for an added link, * -1 for a removed link */ protected void updateDegrees(int e, int incr) { if ( !getEdgeTable().isValidRow(e) ) return; int s = getSourceNode(e); int t = getTargetNode(e); if ( s < 0 || t < 0 ) return; updateDegrees(e, s, t, incr); if ( incr < 0 ) { m_edgeTuples.invalidate(e); } }
/** * Get the VisualItem associated with a source data tuple, if it exists. * @param group the data group from which to lookup the source tuple, * only primary visual groups are valid, focus groups will not work * @param t the source data tuple * @return the associated VisualItem from the given data group, or * null if no such VisualItem exists */ public VisualItem getVisualItem(String group, Tuple t) { TupleSet ts = getVisualGroup(group); VisualTable vt; if ( ts instanceof VisualTable ) { vt = (VisualTable)ts; } else if ( ts instanceof Graph ) { Graph g = (Graph)ts; vt = (VisualTable)(t instanceof Node ? g.getNodeTable() : g.getEdgeTable()); } else { return null; } int pr = t.getRow(); int cr = vt.getChildRow(pr); return cr<0 ? null : vt.getItem(cr); }
/** * Ediflow dedicated method. * @param tuple an obvious tuple * @param alias an alias * @return an attribute value */ public Object getAttributeValueAtOptimized(Tuple tuple, String alias) { prefuse.data.tuple.TupleSet tupleSet = vis.getVisualGroup(groupName); prefuse.visual.VisualTable visualTable; if (tupleSet instanceof prefuse.visual.VisualTable) { visualTable = (prefuse.visual.VisualTable) tupleSet; } else if (tupleSet instanceof prefuse.data.Graph) { prefuse.data.Graph g = (prefuse.data.Graph) tupleSet; visualTable = (VisualTable) (tuple instanceof Node ? g.getNodeTable() : g.getEdgeTable()); } else { return null; } if (visualTable.getSchema().getColumnIndex(getAliasMap().get(alias)) != -1) { return visualTable.get(tuple.getRow(), alias); } else { return null; } }
/** * Get a filtered iterator over the edges and nodes of this graph. * @see prefuse.data.tuple.TupleSet#tuples(prefuse.data.expression.Predicate) */ public Iterator tuples(Predicate filter) { if ( filter == null ) { return tuples(); } else { return new CompositeIterator( m_edgeTuples.iterator(getEdgeTable().rows(filter)), m_nodeTuples.iterator(getNodeTable().rows(filter))); } }
/** * Add an edge to the graph. Both multiple edges between two nodes * and edges from a node to itself are allowed. * @param s the source node id * @param t the target node id * @return the edge id (edge table row number) of the added edge */ public int addEdge(int s, int t) { // get keys for the nodes long key1 = getKey(s); long key2 = getKey(t); // add edge row, set source/target fields Table edges = getEdgeTable(); int r = edges.addRow(); if ( m_longKey ) { edges.setLong(r, m_skey, key1); edges.setLong(r, m_tkey, key2); } else { edges.setInt(r, m_skey, (int)key1); edges.setInt(r, m_tkey, (int)key2); } return r; }
Schema es = graph.getEdgeTable().getSchema(); checkGraphMLSchema(ns); checkGraphMLSchema(es);
prefuse.data.Graph g = (prefuse.data.Graph) tupleSet; visualTable = (VisualTable) (tuple instanceof Node ? g.getNodeTable() : g.getEdgeTable()); } else { return null;
et = addTable(eGroup, graph.getEdgeTable(), filter, edgeSchema);