Prefuse Toolkit: dynamically adding nodes and edges

前端 未结 4 1126
无人及你
无人及你 2020-12-24 11:14

Does anyone have experience with the prefuse graph toolkit? Is it possible to change an already displayed graph, ie. add/remove nodes and/or edges, and have the display corr

4条回答
  •  情深已故
    2020-12-24 12:04

    Okay, after digging a bit through the prefuse sources, I now have a better understanding of how things work under the hood. I found out that actually the new nodes I create with the code above are not only added correctly to the graph, the visualization also takes note of it!

    So, unlike Jerome suggests, it is not necessary to call vis.run("layout") explicitly.

    The reason I thought the nodes were not added correctly was the fact that they are drawn with white background-, border- and text color - on white background that is. Not astonishing that they are a bit difficult to spot.

    To fix that one has to call the color action after a new node is inserted, like this:

    // insert new edge //
    graph.addEdge(oldNode, newNode);
    vis.run("color"); // <- this is new
    

    (Note that this action is defined further up in the code of Example.jar under //-- 4.)

    One last thing I am unsure about now is whether calling this action will make prefuse go over all graph nodes again and set their color - for very large graphs that would be undesired, of course.

提交回复
热议问题