How to solve this problem " The specified superclass 'CyclicLatticeTopology' contains a parse error"?

8 views (last 30 days)
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!

Answers (0)

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!