EdgeCallBack and node manipulation in graph (replacement for lost biograph functionality)
古いコメントを表示
In 2013/4, I was using a current MATLAB version of the time, the Bioinformatics Toolbox and biograph to generate network diagrams and identify errant network paths using that visualization. It worked well. I now seek to use an updated version of that code in R2024a and see that biograph is deprecated and replaced with graph (I only need an undirected graph). However, it appears that some key functionality that I used with biograph is no longer available within graph, unless I'm missing something obvious.
- I don't see how to do an EdgeCallBack to a custom function, which was very useful for breaking bad connections/edges.
- I cannot directly manipulate the position of nodes in the graph after they are displayed, which was previously (with biograph) very useful for disentangling the graph when its initial display was not ideal for identifying bad connections/edges.
Thanks for any advice you have on how to recover this functionality!
回答 (2 件)
recent works
2024 年 4 月 30 日
3 投票
How we can address them with the updated tools.
- EdgeCallBack Functionality: In the newer graph toolbox, you can achieve similar functionality to EdgeCallBack by using callback functions associated with specific events. However, it's important to note that direct manipulation of edges might not be as straightforward as it was with biograph. You may need to handle edge manipulations differently, perhaps by directly modifying the graph structure or using other graph manipulation functions.
- Node Position Manipulation: While the graph toolbox may not provide direct methods for manipulating node positions after display, you can achieve similar results by adjusting the layout algorithm parameters before displaying the graph. Additionally, you might explore other graph layout algorithms or customize the layout to better suit your needs.
To get started, here's a general approach you can take:
- EdgeCallBack Functionality Replacement: Instead of relying on EdgeCallBack, consider using callback functions associated with specific events, such as 'ButtonDownFcn' for mouse clicks on edges. Within these callback functions, you can implement logic to handle edge modifications or perform custom actions.
- Node Position Manipulation: Before displaying the graph, adjust the layout parameters to influence the initial positioning of nodes. You can experiment with different layout algorithms and parameters to achieve a clearer visualization. If needed, you can also explore post-processing techniques to refine the layout further.
For your first comment, could you explain in a little more detail how you used the edge callback to "break bad connections/edges"?
For your second comment, you can query and set the XData and YData properties of the GraphPlot object returned by calling plot on a graph object.
g = graph(bucky);
h = plot(g)
Let's say I wanted to move point 42 to the left a bit. I'm going to call plot with the XData and YData name/value arguments to make sure it initially has the nodes in the same position as the first plot.
figure;
h2 = plot(g, 'XData', h.XData, 'YData', h.YData);
h2.XData(42) = h2.XData(42)-1;
You can also set the XData and YData properties if the nodes have some location information associated with them (like state centroids as one example.)
カテゴリ
ヘルプ センター および File Exchange で Graph and Network Algorithms についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

