本文整理汇总了Java中prefuse.data.Graph.addNode方法的典型用法代码示例。如果您正苦于以下问题:Java Graph.addNode方法的具体用法?Java Graph.addNode怎么用?Java Graph.addNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类prefuse.data.Graph
的用法示例。
在下文中一共展示了Graph.addNode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initDataGroups
import prefuse.data.Graph; //导入方法依赖的package包/类
private void initDataGroups() {
// create sample graph
// 9 nodes broken up into 3 interconnected cliques
Graph g = new Graph();
for ( int i=0; i<3; ++i ) {
Node n1 = g.addNode();
Node n2 = g.addNode();
Node n3 = g.addNode();
}
// add visual data groups
VisualGraph vg = m_vis.addGraph(GRAPH, g);
m_vis.setInteractive(EDGES, null, false);
m_vis.setValue(NODES, null, VisualItem.SHAPE,
new Integer(Constants.SHAPE_ELLIPSE));
AggregateTable at = m_vis.addAggregates(AGGR);
at.addColumn(VisualItem.POLYGON, float[].class);
at.addColumn("id", int.class);
}
示例2: initDataGroups
import prefuse.data.Graph; //导入方法依赖的package包/类
private void initDataGroups() {
// create sample graph
g = new Graph(true);
for (int i = 0; i < 3; ++i) {
Node n1 = g.addNode();
Node n2 = g.addNode();
Node n3 = g.addNode();
g.addEdge(n1, n2);
g.addEdge(n1, n3);
// g.addEdge(n2, n3);
}
g.addEdge(0, 3);
// g.addEdge(3, 6);
g.addEdge(6, 0);
// add labels for nodes and edges
g.addColumn(VisualItem.LABEL, String.class);
for (int i = 0; i < 9; i++) {
g.getNode(i).setString(VisualItem.LABEL, "Node " + i);
}
}
示例3: getClique
import prefuse.data.Graph; //导入方法依赖的package包/类
/**
* Returns a clique of given size. A clique is a graph in which every node
* is a neighbor of every other node.
* @param n the number of nodes in the graph
* @return a clique of size n
*/
public static Graph getClique(int n) {
Graph g = new Graph();
g.getNodeTable().addColumns(LABEL_SCHEMA);
Node nodes[] = new Node[n];
for ( int i = 0; i < n; ++i ) {
nodes[i] = g.addNode();
nodes[i].setString(LABEL, String.valueOf(i));
}
for ( int i = 0; i < n; ++i ) {
for ( int j = i; j < n; ++j )
if ( i != j )
g.addEdge(nodes[i], nodes[j]);
}
return g;
}
示例4: getGrid
import prefuse.data.Graph; //导入方法依赖的package包/类
/**
* Returns a graph structured as an m-by-n grid.
* @param m the number of rows of the grid
* @param n the number of columns of the grid
* @return an m-by-n grid structured graph
*/
public static Graph getGrid(int m, int n) {
Graph g = new Graph();
g.getNodeTable().addColumns(LABEL_SCHEMA);
Node[] nodes = new Node[m*n];
for ( int i = 0; i < m*n; ++i ) {
nodes[i] = g.addNode();
nodes[i].setString(LABEL, String.valueOf(i));
if ( i >= n )
g.addEdge(nodes[i-n], nodes[i]);
if ( i % n != 0 )
g.addEdge(nodes[i-1], nodes[i]);
}
return g;
}
示例5: showTable
import prefuse.data.Graph; //导入方法依赖的package包/类
/**
* Creates visible node for given table.
*
* @param graph the graph
* @param table the table to show
*/
private boolean showTable(Graph graph, Table table) {
if (table != null && !tableNodes.containsKey(table)) {
Node n = graph.addNode();
n.setString("label", table.getName());
String tooltip = tableRenderer.getToolTip(table);
n.setString("tooltip", tooltip);
tableNodes.put(table, n);
return true;
}
return false;
}
示例6: initDataGroups
import prefuse.data.Graph; //导入方法依赖的package包/类
private void initDataGroups() {
// create sample graph
// 9 nodes broken up into 3 interconnected cliques
Graph g = new Graph();
for ( int i=0; i<3; ++i ) {
Node n1 = g.addNode();
Node n2 = g.addNode();
Node n3 = g.addNode();
g.addEdge(n1, n2);
g.addEdge(n1, n3);
g.addEdge(n2, n3);
}
g.addEdge(0, 3);
g.addEdge(3, 6);
g.addEdge(6, 0);
// add visual data groups
VisualGraph vg = m_vis.addGraph(GRAPH, g);
m_vis.setInteractive(EDGES, null, false);
m_vis.setValue(NODES, null, VisualItem.SHAPE,
new Integer(Constants.SHAPE_ELLIPSE));
AggregateTable at = m_vis.addAggregates(AGGR);
at.addColumn(VisualItem.POLYGON, float[].class);
at.addColumn("id", int.class);
// add nodes to aggregates
// create an aggregate for each 3-clique of nodes
Iterator nodes = vg.nodes();
for ( int i=0; i<3; ++i ) {
AggregateItem aitem = (AggregateItem)at.addItem();
aitem.setInt("id", i);
for ( int j=0; j<3; ++j ) {
aitem.addItem((VisualItem)nodes.next());
}
}
}
示例7: initDataGroups
import prefuse.data.Graph; //导入方法依赖的package包/类
private void initDataGroups() {
// create sample graph
// 9 nodes broken up into 3 interconnected cliques
Graph g = new Graph();
for ( int i=0; i<3; ++i ) {
Node n1 = g.addNode();
Node n2 = g.addNode();
Node n3 = g.addNode();
g.addEdge(n1, n2);
g.addEdge(n1, n3);
g.addEdge(n2, n3);
}
g.addEdge(0, 3);
g.addEdge(3, 6);
g.addEdge(6, 0);
// add visual data groups
VisualGraph vg = m_vis.addGraph(GRAPH, g);
m_vis.setInteractive(EDGES, null, false);
m_vis.setValue(NODES, null, VisualItem.SHAPE,
new Integer(Constants.SHAPE_ELLIPSE));
AggregateTable at = m_vis.addAggregates(AGGR);
at.addColumn(VisualItem.POLYGON, float[].class);
at.addColumn("id", int.class);
// add nodes to aggregates
// create an aggregate for each 3-clique of nodes
Iterator<?> nodes = vg.nodes();
for ( int i=0; i<3; ++i ) {
AggregateItem aitem = (AggregateItem)at.addItem();
aitem.setInt("id", i);
for ( int j=0; j<3; ++j ) {
aitem.addItem((VisualItem)nodes.next());
}
}
}
示例8: initDataGroups
import prefuse.data.Graph; //导入方法依赖的package包/类
private void initDataGroups() {
// create sample graph
// 9 nodes broken up into 3 interconnected cliques
Graph g = new Graph();
for ( int i=0; i<3; ++i ) {
Node n1 = g.addNode();
Node n2 = g.addNode();
Node n3 = g.addNode();
g.addEdge(n1, n2);
g.addEdge(n1, n3);
g.addEdge(n2, n3);
}
g.addEdge(0, 3);
g.addEdge(3, 6);
g.addEdge(6, 0);
// add labels for nodes and edges
g.addColumn(VisualItem.LABEL, String.class);
for (int i = 0; i < 9; i++) {
g.getNode(i).setString(VisualItem.LABEL, ""+i);
g.getEdge(i).setString(VisualItem.LABEL, ""+i);
}
// add visual data groups
VisualGraph vg = m_vis.addGraph(GRAPH, g);
m_vis.setInteractive(EDGES, null, false);
m_vis.setValue(NODES, null, VisualItem.SHAPE,
new Integer(Constants.SHAPE_ELLIPSE));
AggregateTable at = m_vis.addAggregates(AGGR);
at.addColumn(VisualItem.POLYGON, float[].class);
at.addColumn("id", int.class);
// add nodes to aggregates
// create an aggregate for each 3-clique of nodes
Iterator nodes = vg.nodes();
for ( int i=0; i<3; ++i ) {
AggregateItem aitem = (AggregateItem)at.addItem();
aitem.setInt("id", i);
for ( int j=0; j<3; ++j ) {
aitem.addItem((VisualItem)nodes.next());
}
}
}
示例9: getNodes
import prefuse.data.Graph; //导入方法依赖的package包/类
/**
* Builds a completely unconnected (edge-free) graph with the given
* number of nodes
* @param n the number of nodes
* @return a graph with n nodes and no edges
*/
public static Graph getNodes(int n) {
Graph g = new Graph();
g.getNodeTable().addColumns(LABEL_SCHEMA);
for ( int i=0; i < n; i++ ) {
Node node = g.addNode();
node.setString(LABEL, String.valueOf(i));
}
return g;
}
示例10: getStar
import prefuse.data.Graph; //导入方法依赖的package包/类
/**
* Builds a "star" graph with one central hub connected to the given
* number of satellite nodes.
* @param n the number of points of the star
* @return a "star" graph with n points, for a total of n+1 nodes
*/
public static Graph getStar(int n) {
Graph g = new Graph();
g.getNodeTable().addColumns(LABEL_SCHEMA);
Node r = g.addNode();
r.setString(LABEL, "0");
for ( int i=1; i <= n; ++i ) {
Node nn = g.addNode();
nn.setString(LABEL, String.valueOf(i));
g.addEdge(r, nn);
}
return g;
}
示例11: initDataGroups
import prefuse.data.Graph; //导入方法依赖的package包/类
/**
* Inits the data groups.
*
* @param orderedTerms
* the ordered terms
* @param dm
* the dm
* @param separateConstants
* the separate constants
* @throws FeatureTermException
* the feature term exception
* @throws IOException
* Signals that an I/O exception has occurred.
*/
private void initDataGroups(final List<FeatureTerm> orderedTerms, final FTKBase dm, boolean separateConstants)
throws FeatureTermException, IOException {
Graph g = new Graph(true);
g.addColumn("id", Integer.class);
g.addColumn("name", String.class);
// Create nodes:
for (@SuppressWarnings("unused")
FeatureTerm t : orderedTerms) {
g.addNode();
}
setColors(true);
assignColors(orderedTerms);
if (locations == null) {
locations = new Point2D[orderedTerms.size()];
for (int i = 0; i < orderedTerms.size(); i++) {
locations[i] = new Point2D.Double(rand.nextDouble(), rand.nextDouble());
}
}
vg = m_vis.addGraph(GRAPH, g);
try {
distances(orderedTerms);
} catch (InterruptedException e) {
FTLGUI.writeConsole(e.toString());
e.printStackTrace();
}
applyForces(orderedTerms);
drawCaseBase(orderedTerms);
}
示例12: addEdges
import prefuse.data.Graph; //导入方法依赖的package包/类
/**
* Adds edges for all associations of a table.
*
* @param table the table
* @param toRender is not null, the only association to make visible
*
* @return list of newly rendered tables
*/
private List<Table> addEdges(Graph g, Table table, Association toRender, List<Table> toCheck, boolean visibleDestinationRequired) {
List<Table> result = new ArrayList<Table>();
toCheck.add(table);
for (Association a: table.associations) {
if (toRender != null && toRender != a) {
continue;
}
if (!isVisualizable(a) && (toRender == null || a != toRender)) {
continue;
}
if (visibleDestinationRequired && !tableNodes.containsKey(a.destination)) {
continue;
}
if (!renderedAssociations.containsKey(a) && !renderedAssociations.containsKey(a.reversalAssociation)) {
toCheck.add(a.destination);
toCheck.add(a.source);
if (showTable(g, a.source)) {
result.add(a.source);
}
if (showTable(g, a.destination)) {
result.add(a.destination);
}
String tooltip = a.getJoinCondition();
if (!associationIsUnique(a)) {
Node an = g.addNode();
an.set("association", a);
an.setString("label", a.getName() + "#");
an.setString("tooltip", tooltip);
renderedAssociationsAsNode.put(a, an);
Edge ae = g.addEdge(an, tableNodes.get(a.source));
ae.set("association", a.reversalAssociation);
ae.set("full", Boolean.FALSE);
ae.setString("tooltip", tooltip);
renderedAssociations.put(a.reversalAssociation, ae);
Edge be = g.addEdge(an, tableNodes.get(a.destination));
be.set("association", a);
be.set("full", Boolean.FALSE);
be.setString("tooltip", tooltip);
renderedAssociations.put(a, be);
} else {
Edge e = g.addEdge(tableNodes.get(a.source), tableNodes.get(a.destination));
e.set("association", a);
e.set("full", Boolean.TRUE);
e.setString("tooltip", tooltip);
renderedAssociations.put(a, e);
}
}
}
return result;
}
示例13: create
import prefuse.data.Graph; //导入方法依赖的package包/类
/**
* adds random data (nodes & connections) to a given GraphDataModifier
*
* @param graph (PrefuseGraph)
* @return GraphDataModifier (PrefuseGraph) with random nodes and connections
*/
public Graph create(Graph graph) {
graph = GraphAddColumnDefinition.addColumnDefinition(graph);
Random rnd = new Random();
// GraphDataModifier random Nodes with random data
for (int i = 0; i <= COUNT_NODES; i++) {
Node n = graph.addNode();
// add random data (later use protege data)
n.set(ColumnNames.ID, rnd.nextInt(25000));
n.set(ColumnNames.NODE_HEIGHT, rnd.nextInt(35));
n.set(ColumnNames.NODE_WIDTH, rnd.nextInt(35));
n.set(ColumnNames.TEXT_SIZE, rnd.nextInt(12));
n.set(ColumnNames.COLOR_RED, rnd.nextInt(250));
n.set(ColumnNames.COLOR_GREEN, rnd.nextInt(250));
n.set(ColumnNames.COLOR_BLUE, rnd.nextInt(250));
n.set(ColumnNames.TEXT_COLOR_RED, rnd.nextInt(250));
n.set(ColumnNames.TEXT_COLOR_GREEN, rnd.nextInt(250));
n.set(ColumnNames.TEXT_COLOR_BLUE, rnd.nextInt(250));
n.set(ColumnNames.TEXT_BACKGROUND_COLOR_RED, rnd.nextInt(250));
n.set(ColumnNames.TEXT_BACKGROUND_COLOR_BLUE, rnd.nextInt(250));
n.set(ColumnNames.TEXT_BACKGROUND_COLOR_GREEN, rnd.nextInt(250));
n.set(ColumnNames.TEXT_BACKGROUND_STROKE_COLOR_RED, rnd.nextInt(250));
n.set(ColumnNames.TEXT_BACKGROUND_STROKE_COLOR_BLUE, rnd.nextInt(250));
n.set(ColumnNames.TEXT_BACKGROUND_STROKE_COLOR_GREEN, rnd.nextInt(250));
n.setString(ColumnNames.NAME, "Node" + rnd.nextInt(100));
n.setString(ColumnNames.FULL_NAME, "Node" + rnd.nextInt(100));
n.set(ColumnNames.NODE_FORM, Nodetype.nodetype[rnd.nextInt(3)]);
n.set(ColumnNames.NODE_VOWL_TYPE, Nodetype.vowltype[rnd.nextInt(3)]);
n.set(ColumnNames.CLASS_INSTANCE_COUNT, rnd.nextInt(20));
}
// GraphDataModifier random connections
for (int i = 0; i <= COUNT_CONNECTIONS; i++) {
int a = rnd.nextInt(COUNT_NODES);
int b = rnd.nextInt(COUNT_NODES);
int edgeID = graph.addEdge(a, b);
Edge edge = graph.getEdge(edgeID);
edge.setString(ColumnNames.NAME, "Edge" + rnd.nextInt(100));
edge.setString(ColumnNames.FULL_NAME, "Edge" + rnd.nextInt(100));
edge.set(ColumnNames.TEXT_SIZE, rnd.nextInt(8));
edge.set(ColumnNames.TEXT_COLOR_RED, rnd.nextInt(250));
edge.set(ColumnNames.TEXT_COLOR_GREEN, rnd.nextInt(250));
edge.set(ColumnNames.TEXT_COLOR_BLUE, rnd.nextInt(250));
edge.set(ColumnNames.TEXT_BACKGROUND_COLOR_RED, rnd.nextInt(250));
edge.set(ColumnNames.TEXT_BACKGROUND_COLOR_BLUE, rnd.nextInt(250));
edge.set(ColumnNames.TEXT_BACKGROUND_COLOR_GREEN, rnd.nextInt(250));
edge.set(ColumnNames.TEXT_BACKGROUND_STROKE_COLOR_RED, rnd.nextInt(250));
edge.set(ColumnNames.TEXT_BACKGROUND_STROKE_COLOR_BLUE, rnd.nextInt(250));
edge.set(ColumnNames.TEXT_BACKGROUND_STROKE_COLOR_GREEN, rnd.nextInt(250));
edge.set(ColumnNames.COLOR_RED, rnd.nextInt(250));
edge.set(ColumnNames.COLOR_GREEN, rnd.nextInt(250));
edge.set(ColumnNames.COLOR_BLUE, rnd.nextInt(250));
edge.set(ColumnNames.EDGE_ARROW_TYPE, EdgesType.arrowtype[rnd.nextInt(3)]);
edge.set(ColumnNames.EDGE_LINE_TYPE, EdgesType.linetype[rnd.nextInt(3)]);
edge.set(ColumnNames.ID, rnd.nextInt(25000));
edge.set(ColumnNames.EDGE_LENGTH, rnd.nextInt(100));
}
return graph;
}
示例14: getTestHw
import prefuse.data.Graph; //导入方法依赖的package包/类
public static Graph getTestHw() {
Graph g = new Graph();
g.addColumn("name", String.class);
g.addColumn("type", String.class);
g.addColumn("mark", Boolean.class);
// On Edge
g.addColumn("springCoefficient", float.class);
g.addColumn("springLength", float.class);
// On Node
g.addColumn("massValue", float.class);
g.addColumn("image", String.class);
// Create 1 router
Node router = g.addNode();
router.set("name", "Router");
router.set("type", "Router");
router.set("image", "images/router.jpg");
Node rif1 = g.addNode();
rif1.set("name", "Router-IF-1");
rif1.set("type", "NIC");
rif1.set("image", "images/nic.gif");
Node rif2 = g.addNode();
rif2.set("name", "Router-IF-2");
rif2.set("type", "NIC");
rif2.set("image", "images/nic.gif");
Node rif3 = g.addNode();
rif3.set("name", "Router-IF-3");
rif3.set("type", "NIC");
rif3.set("image", "images/nic.gif");
Node rif4 = g.addNode();
rif4.set("name", "Router-IF-4");
rif4.set("type", "NIC");
rif4.set("image", "images/nic.gif");
Node wifi = g.addNode();
wifi.set("name", "Router-WIFI");
wifi.set("type", "NIC");
wifi.set("image", "images/nic-wifi.png");
addEdge(g, rif1, router, "ComposedOf");
addEdge(g, rif2, router, "ComposedOf");
addEdge(g, rif3, router, "ComposedOf");
addEdge(g, rif4, router, "ComposedOf");
addEdge(g, wifi, router, "ComposedOf");
addServer(g, "Server-1", "UTP", rif1);
addServer(g, "Server-2", "UTP", rif2);
addServer(g, "Server-3", "UTP", rif3);
addServer(g, "Server-4", "UTP", rif4);
for (int i = 0; i < 10; i++) {
addServer(g, "Server-wifi-" + i, "WIFI", wifi);
}
return(g);
}
示例15: addServer
import prefuse.data.Graph; //导入方法依赖的package包/类
private static Node addServer(Graph g, String name, String connectionType, Node rif) {
Node n = g.addNode();
n.set("name", name);
n.set("type", "Server");
n.set("image", "images/computer.png");
// add a nic
Node nic = g.addNode();
nic.set("name", "NIC-" + name);
nic.set("type", "NIC");
if (connectionType.equals("WIFI")) {
nic.set("image", "images/nic-wifi.png");
} else {
nic.set("image", "images/nic.gif");
}
addEdge(g, nic, n, "ComposedOf");
// Connect nic to router IF.
addEdge(g, nic, rif, connectionType);
// Add OS + Programs..
Node os = g.addNode();
os.set("name", "OS");
os.set("type", "OS");
os.set("image", "images/vista.jpg");
addEdge(g, os, n, "RunsOn");
for (int i = 0; i < 10; i++) {
Node p = g.addNode();
p.set("name", "Application");
p.set("type", "Application");
p.set("image", "images/ssh.png");
addEdge(g, p, os, "InstalledOn");
}
return(n);
}