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

  • SEARCH
  • Home
  • 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 9289631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T20:13:41+00:00 2026-06-18T20:13:41+00:00

In cytoscape.js, I’m trying to change the values of two node attributes, for each

  • 0

In cytoscape.js, I’m trying to change the values of two node attributes, for each node in a 329-node network.

This works, but takes 86 seconds. I was hoping it would be much faster. Here is my code:

var data = // data of the form {lfc: {key1: 0.01, key2: 0.02, ...}, pval: {key1: 0.03,  key2: 0.04, ...}};
var nodes = cy.nodes();
console.log('starting to update node data...');
var start = new Date().getTime();
for (var i = 0; i < nodes.length; i++)
{
  var node = nodes[i];
  var id = node.data("id");
  var lfc = data['lfc'][id];
  var pval = data['pval'][id];
  node.data({lfc: lfc, pval: pval});
}
var end = new Date().getTime();
console.log("finished in " + (end - start) + "ms");

I know if I am setting the attributes of all nodes in the network to the same value, it’s much faster. This takes about half a second:

var start = new Date().getTime();
cy.nodes().data({lfc: 1.0, pval: 1.0});
var end = new Date().getTime();
console.log("finished in " + (end - start) + "ms");

But since I’m trying to give each node individual values, I can’t do this.

Any ideas for improving performance?

  • 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-18T20:13:42+00:00Added an answer on June 18, 2026 at 8:13 pm

    The problem with calling functions like that in a loop is that each iteration causes events and notifications to the renderer — because visual updates may be needed. As you noted, this is not an issue when adding/loading in bulk, because this only generates one notification.

    The ideal architecture would be to load in all the elements you need before intialising cytoscape.js, and then updating individual nodes as they change on the server. Polling the server and updating all the nodes will likely cause you other issues other than loading performance.

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

Sidebar

Related Questions

I know this questions has been asked many times before -- but I haven't
Is there a direct way to get all network neighbors of a node n0
In the past I've using graphviz's node label, URL (or href) and tooltip attributes
I recently found out about Cytoscape.js and would like to try out the force-directed
I have a project with multiple modules, each in its own directory. Each module
I've looked at a number of packages for graph layout (Graphviz, Gephi, Cytoscape, NetworkX
So I'm not sure how stackoverflow friendly this question is since it doesn't have
I am trying to build graphs using tree-like data, where nodes typically split into
How can you detect if the client browser has SSL support? I am not
I'm having a problem getting the javac used by Ant to find and use

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.