Branch removal cause error in plotting graph with coordinates
2 views (last 30 days)
I have a graph of 124 edges and 125 vertices, then I remove some branches randomly:
then when I want to plot the graph:
I got the following error:
Expected XData to be an array with number of elements equal to 124.
I know its because graph function reduces number of nodes, but I don't want to, my node coordinates are fixed. Please would anyone give me some help?
Devyani Maladkar on 25 Aug 2021
I understand from your question that you are plotting a graph and want to remove some branches randomly. Since you have a fixed number of nodes and node coordinates you don't want to remove the nodes, which results in the error.
Since you have fixed node coordinates, you can specify beforehand the total number of nodes. This can be done by specifying when graph object is created as below:
The extra nodes are disconnected from the primary connected component.
For more information on creating the graph object using the above argument you can refer to the documentation under the section Edge List Construction with Extra Nodes. The documentation link refers to R2021a release but will work for R2015b release as well.
If you would like to refer to archived documentation, you can access it from the following link: https://www.mathworks.com/help/doc-archives.html .
For access to earlier releases, please contact support.