Creating a graph out of a string list?

Here’s one way to get the adjacency matrix:

str = [" 'DataManager' ", " 'LauncherFrame' ", " 'DataManager' ", " 'DataManager' ", " 'DataManager' ", " 'DataManager' ", " 'DataManager' ", " 'DataManager' ", " 'DataManager' ", " 'DataManager' ", " 'ToolBox' ", " 'ToolBox' ", " 'ToolBox' ", " 'ToolBox' ", " 'ToolBox' ", " 'MonoWellInterpretationView' ", " 'MonoWellInterpretationView' ", " 'MonoWellInterpretationView' ", " 'MonoWellInterpretationView' ", " 'MonoWellInterpretationView' ", " 'MonoWellInterpretationView' ", " 'MonoWellInterpretationView' ", " 'MonoWellInterpretationView' ", " 'MonoWellInterpretationView' ", " 'MonoWellInterpretationView' ", " 'MonoWellInterpretationView' ", " 'ToolBox' ", " 'DataManager' ", " 'DataManager' ", " 'DataManager' ", " 'DataManager' "]

d = Dict(unique(str) .=> 1:length(unique(str)))
A = zeros(Int, length(d), length(d))
for i in 1:length(str)-1
    A[d[str[i]], d[str[i+1]]] += 1
end
1 Like