How to solve this problem " The specified superclass 'CyclicLatticeTopology' contains a parse error"?
12 views (last 30 days)
Show older comments
Commented: Rayan Glus on 10 Oct 2021
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
% 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
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;
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;
obj.W(logical(eye(obj.N))) = 0;
function s = getDescription(obj)
s = sprintf('Small world network');
Note: I use MATLAB 2018a
I would appreciate your help.
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!