Invalid MEX-file error when using betweenness_centrality.m script - not sure why!
Mostrar comentarios más antiguos
Hey all,
I am trying to run the 'betweenness_centrality.m' script from the MatlabBGL package.
I am using a 64-bit macbook air and am using the matlab version 'Matlab2023a'.
However, when I try to run it, I get the following error:
Invalid MEX-file '/Users/macbook/Desktop/UCL PhD
Work/py_scripts/betweenness_centrality_mex.mexmaci64':
dlopen(/Users/macbook/Desktop/UCL PhD
Work/py_scripts/betweenness_centrality_mex.mexmaci64, 0x0006): Library not loaded:
'@loader_path/libmex.dylib'
Referenced from: '/Users/macbook/Desktop/UCL PhD
Work/py_scripts/betweenness_centrality_mex.mexmaci64'
Reason: tried: '/Users/macbook/Desktop/UCL PhD Work/py_scripts/libmex.dylib' (no
such file), '/usr/local/lib/libmex.dylib' (no such file),
'/usr/lib/libmex.dylib' (no such file)
Error in betweenness_centrality (line 110)
bc = betweenness_centrality_mex(A,weight_arg);
Error in Spacesocialproject (line 3)
bc = betweenness_centrality(G);
I have ensured that the 'betweenness_centrality_mex.mexmaci64' file is in the same directory as the matlab scripts.
I would be so grateful for a helping hand as to why this may be!
6 comentarios
Steven Lord
el 31 de Mayo de 2023
This isn't a direct answer to your question about the MEX-file in that third-party package but are you aware that MATLAB now has (and has had, for several years) graph and network algorithm functionality? The centrality function for graph and digraph objects can compute betweenness centrality.
Emre
el 31 de Mayo de 2023
I don't have any experience with the MatlabBGL third-party toolbox, but I suspect from the fact that you're calling import that you're trying to use the functions it contains. If the G you pass into graph is the adjacency matrix, you can do the same thing using the functionality included in MATLAB if you restart your session (to remove the import) and call the graph function in MATLAB.
rng default
A = sprand(10, 10, 0.25); % Random adjacency matrix
G = graph(A+A');
C = centrality(G, 'betweenness')
We can visualize the graph and highlight the "most central" node.
h = plot(G);
[~, mostCentral] = max(C);
highlight(h, mostCentral, 'MarkerSize', 2*h.MarkerSize) % Double its size
Emre
el 31 de Mayo de 2023
Looks like they differ by a scaling factor.
format longg
P = [0.28888888888888886, 0.28888888888888886, 0.28888888888888886, 0.25742574257425743];
M = [0.0111, 0.0111, 0.0111, 0.0099];
scaleFactor = P./M
I'm betting if you actually used all the decimal places stored in the values in MATLAB each element of the scaling factor vector would be even closer to the same number.
I don't know what scaling factor or method Python uses. If you forced me to guess perhaps their definition doesn't divide by
like the definition on the centrality documentation page does?
Emre
el 31 de Mayo de 2023
Respuestas (0)
Categorías
Más información sobre Call Python from MATLAB en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
