matlab - Finding the diameter of a graph -
In MATLAB, I left [0,1] X [0,1] equally evenly digits I am I keep the distance between the two points less than 0.25. To do this, the code (and the resulting graph is under plot).
num_Rx = 50 Rx_positions = rand (num_Rx, 2); Generate edges between pairs of ideal for% 0.25. Adj_matrix = Void (num_Rx, num_Rx); I for = 1: num_Rx j = i + 1: num_Rx dist = norm (Rx_positions (i, :) - Rx_positions (j, :)); If the District & lt; 0.25; Adj_matrix (i, j) = 1; End end end data gplot (adj_matrix, Rx_positions)
i.e. This is an unspecified graph, the weight of all is equal to 1.
In diameter I want to say the graphallshortestpaths () (), and want to take the maximum value (diameter is the longest path to the longest).
However, I am having difficulty calling this function - I can not understand how to call like examples, with my proximity matrix and / or my list node statuses. Especially I can not understand any example, how the given matlab code matches that data
How do I go about doing this?
It seems that you're missing out on all '' your merged matrix with a sparse matrix Converting to It should give you what you need:
adj_sparse = sparse (adj_matrix); Distance = graphs shortpest (adj_sparse); % If you do not care which nodes% produce the shortest route for the longest, then in a longer and short time; Long_sub [diameter, tall_finance] = max (distance (:)); Long_sub = ind2sub (size (distance), tall_in);
Comments
Post a Comment