example of using graph (in mathematical sense) functions. H/t to question from lpycmm during last matlab lab class
ds 2019-10-31, halloween. denis schluppeck
Matlab is awesome and of course there is a way to do it - even though I didn't know too much about all the available functions until I started looking a bit more 😉
Actually, you could look at other options. If you are trying to just visualise graph related data (and not do too many computations), an existing package might be all you need. Things to look for:
- look at
R,rstatspackages calledigraphandigraphdatain particular pythonbindings for the sameigraphlibrary.- a
unixcommand line tool calledDOT, https://en.wikipedia.org/wiki/DOT_(graph_description_language) - a nice wrapper around different layout engines called
graphviz(AT&T) https://www.graphviz.org/
Have a look at the the example_graphs.m file in this gist to get started. Things to think about are:
- where does the adjacency matrix come from (data? calculations)
- what to do for directed versus non-directed graphs.
A minimal example would be:
% mock up a adjacency matrix
% 25 vertices, people, things connected
A = rand(25) < 0.4;
B = triu(A) + tril(A',-1);
% turn into a graph object (vertices and edges)
G = graph(B)
plot(G)
title('a graph!')
% as always - dig through documentation...
doc graph
