How to solve this problem " The specified superclass 'CyclicLatticeTopology' contains a parse error"?
    5 次查看(过去 30 天)
  
       显示 更早的评论
    
I get this error whenever I try to run the following code which I found on FileExchange:
The specified superclass 'CyclicLatticeTopology' contains a parse error, cannot be found on MATLAB's search path, or is shadowed by another file with the same name.
% SmallWorldTopology - Small world topology
%   This is a small world network topology, i.e., a graph with a very low
%   diameter despite a relatively low mean degree of the nodes. This is
%   constructed using the so-called Watts-Strogatz mechanism:
%
%       1) A cyclic lattice is constructed, with K/2 neighbors for each
%       node.
%       2) Every connection is randomly rewired with probability 'beta'.
%
%   Initialize it with the K and beta parameters:
%
%       t = SmallWorldTopology(N, K, beta);
classdef SmallWorldTopology < CyclicLatticeTopology
    properties
        beta;
    end
    methods
        function obj = SmallWorldTopology(N, K, beta)
            obj = obj@CyclicLatticeTopology(N, K);
            assert(isinrange(beta), 'Lynx:Runtime:Validation', 'The beta parameter of SmallWorldTopology must be in [0, 1]');
            obj.beta = beta;
        end
        function obj = construct(obj)
            obj = obj.construct@CyclicLatticeTopology();
            for i = 1:obj.N
                neighbors = obj.getNeighbors(i);
                dice = rand(length(neighbors), 1) < obj.beta;
                toBeRewired = neighbors(dice);
                for j = 1:length(toBeRewired)
                    newNeighbor = randi(obj.N, 1);
                    obj.W(i, toBeRewired(j)) = 0;
                    obj.W(toBeRewired(j), i) = 0;
                    obj.W(i, newNeighbor) = 1;
                    obj.W(newNeighbor, i) = 1;
                end
            end
            obj.W(logical(eye(obj.N))) = 0;
        end
        function s = getDescription(obj)
            s = sprintf('Small world network');
        end
    end
end
Note: I use MATLAB 2018a 
I would appreciate your help.
Thanks!
2 个评论
  Walter Roberson
      
      
 2021-10-10
				Do you have https://www.mathworks.com/matlabcentral/fileexchange/48490-lynx-matlab-toolbox installed and on your path from running its install() function ?
回答(0 个)
另请参阅
类别
				在 Help Center 和 File Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

