EdgeCallBack and node manipulation in graph (replacement for lost biograph functionality)

조회 수: 9 (최근 30일)
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.
  1. I don't see how to do an EdgeCallBack to a custom function, which was very useful for breaking bad connections/edges.
  2. 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
recent works 2024년 4월 30일
How we can address them with the updated tools.
  1. 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.
  2. 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:
  1. 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.
  2. 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.

Steven Lord
Steven Lord 2024년 4월 30일
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)
h =
GraphPlot with properties: NodeColor: [0 0.4470 0.7410] MarkerSize: 4 Marker: 'o' EdgeColor: [0 0.4470 0.7410] LineWidth: 0.5000 LineStyle: '-' NodeLabel: {1x60 cell} EdgeLabel: {} XData: [0.1033 1.3374 2.2460 1.3509 0.0019 -1.0591 -2.2901 -2.8275 -1.9881 -0.8836 1.5240 0.4128 0.6749 1.9866 2.5705 3.3263 3.5310 3.9022 3.8191 3.5570 ... ] (1x60 double) YData: [-1.8039 -1.2709 -2.0484 -3.0776 -2.9916 -0.9642 -1.2170 0.0739 1.0849 0.3856 0.1564 0.9579 2.2450 2.1623 0.8879 -1.2600 0.0757 0.8580 -0.4702 ... ] (1x60 double) ZData: [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] Use GET to show all properties
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.)
  댓글 수: 1
Joseph MacGregor
Joseph MacGregor 2024년 5월 1일
Hi Steven,
Thanks for the quick and thorough response. Some more details from me. I went through the graph docs and properties and experimentation did not reveal an obvious answer.
  1. With respect to "breaking bad connections/edges", I may have complicated the issue by overexplaining what my custom callback function would be doing to the underlying dataset. Put more simply, is there a way to generate a custom callback function for an edge in a graph that can be accessed via right-click? There used to be for biograph.
  2. Your example makes complete sense to me, but it isn't interactive, which is what I was hoping might still be possible. In biograph, you could click on a node and then drag it to a new location. Is that possible in graph?
The broader thrust of my question is whether functionality that existed in biograph might somehow still be accessed via graph?
Thanks,
Joe

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Graph and Network Algorithms에 대해 자세히 알아보기

제품


릴리스

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by