Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7994163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:03:48+00:00 2026-06-04T14:03:48+00:00

I’m trying to create a dynamically-updated Prefuse graph, where nodes are added and deleted

  • 0

I’m trying to create a dynamically-updated Prefuse graph, where nodes are added and deleted regularly. I’ve been able to add nodes and edges fine, and then delete them, but I get exceptions when I try to add edges to the next set of nodes. Does anyone know of any pitfalls in removing nodes from a Prefuse graph? Or, does anyone know a better way to interact with a Prefuse graph dynamically?

(Note that the display is updating fine; at all times the display seems to match the contents of the graph. This isn’t a dupe of Prefuse Toolkit: dynamically adding nodes and edges)

Code excerpts:

// Set up edge and node tables
Schema node_schema = new Schema();
Schema edge_schema = new Schema();
node_schema.addColumn("node_info", NodeInfo.class);
edge_schema.addColumn("source", int.class, 0);
edge_schema.addColumn("target", int.class, 0);
edge_schema.addColumn("edge_info", EdgeInfo.class);
graph_nodes = node_schema.instantiate();
graph_edges = edge_schema.instantiate();

...

// Set up visualization
graph = new Graph(graph_nodes, graph_edges, false);
vis_panel = new MyVisPanel(graph);

...

// Add nodes & edges
int new_node_1 = graph_nodes.addRow();
graph_nodes.set(new_node_1, "node_info", new NodeInfo());
int new_node_2 = graph_nodes.addRow();
graph_nodes.set(new_node_2, "node_info", new NodeInfo());
int new_edge = graph_edges.addRow();
graph_edges.set(new_edge, "target", new_node_1);
graph_edges.set(new_edge, "source", new_node_2);

... 

// Remove nodes
TupleSet nodes = graph.getNodes();
Iterator iter = nodes.tuples(my_predicate);
while(iter.hasNext())
{
    int row_to_delete = ((Tuple) iter.next()).getRow();
    if(graph.removeNode(row_to_delete))
    {
        System.out.println("Removed row " + row_to_delete);
    }
}

...

// Add nodes & edges again
int new_node_1 = graph_nodes.addRow();
graph_nodes.set(new_node_1, "node_info", new NodeInfo());
int new_node_2 = graph_nodes.addRow();
graph_nodes.set(new_node_2, "node_info", new NodeInfo());
int new_edge = graph_edges.addRow(); // <<-- Exception is thrown here
graph_edges.set(new_edge, "target", new_node_1);
graph_edges.set(new_edge, "source", new_node_2);

The exception I get is:

java.lang.IllegalArgumentException: Row index out of bounds: -1
    at prefuse.data.column.IntColumn.getInt(Unknown Source)
    at prefuse.data.Table.getInt(Unknown Source)
    at prefuse.data.Graph.updateDegrees(Unknown Source)
    at prefuse.data.Graph.updateDegrees(Unknown Source)
    at prefuse.data.Graph$Listener.tableChanged(Unknown Source)
    at prefuse.data.Table.fireTableEvent(Unknown Source)
    at prefuse.data.Table.addRow(Unknown Source)
    at my_pkg.addSomeNodesFunction(my_code.java:99)

I have not used the standard Graph.addNode() and addEdge() methods, because it seemed harder to set edge information that way. (if there’s a better way to do this, let me know!) The delete is succeeding, in that graph.getNodeCount() and graph.getEdgeCount() return smaller numbers after deleting the nodes.

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T14:03:49+00:00Added an answer on June 4, 2026 at 2:03 pm

    After more investigation this appears to be a minor bug in prefuse. Calls to addEdge first initialize the source and target node numbers to 0, after which the graph tries to update its degree counts, which fails if node 0 does not exist. See bug report 3529747 on their SF page for more information.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I am trying to loop through a bunch of documents I have to put

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.