Add Edges to Network Graph Without Changing the Layout
Afficher commentaires plus anciens
I have two adjacency matrices that each contain the same nodes, but contain different edges. I can very easily plot these two graphs separately, or I can combine them, and plot them all together, but I'm having trouble combing them in the way that I want. I want the layout of the nodes to only reflect the edges contained in the first dataset, such that there locations do not take into account the second set of edges from the second adjacency matrix. Pics added for clarity, with the last one ("What I Want") faked in MS Paint. Code will read something like
%A1 = Adjacency Matrix 1, A2 = Adjacency Matrix 2
figure()
G1 = graph(A1)
G2 = graph(A2)
P1=plot(G1,'EdgeColor','k')
layout(P1,'force','usegravity',true)
G1=addedge(G1,G2.Edges)
highlight(P1,G2,'EdgeColor','b')
% This code fails because the edges that I am attempting to highlight do not exist in the plot P1.
% If I replot P1 after adding the edges from G2, then the layout changes.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Graph and Network Algorithms dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!