Hi all,
I am reading this post:
but when I try the code:
# Load the packages
using LightGraphs, GraphPlot, MetaGraphs, GraphRecipes, Plots
# Load the adjacency matrix and graph attributes
mat_arcTwoNodes = [0 1 0 0 0 0 0 0 0 0;
0 0 0 0 0 1 0 0 0 0;
0 0 0 0 0 0 0 0 0 1;
1 0 0 0 1 0 0 0 0 0;
0 0 0 0 0 1 0 0 0 0;
1 0 0 1 0 0 0 1 0 0;
0 1 1 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 1 0;
0 0 0 0 1 0 0 0 0 0;
0 0 0 0 0 1 1 0 1 0]
vec_xNode = [1 3 8 2 4 5 6 7 9 9]
vec_yNode = [1 2 1 7 9 5 3 7 9 4]
# Create a generic graph
gr = SimpleDiGraph()
add_vertices!(gr, size(mat_arcTwoNodes, 1))
# Add edges based on the adjacency matrix
for i in 1:size(mat_arcTwoNodes, 1), j in 1:size(mat_arcTwoNodes, 2)
if mat_arcTwoNodes[i,j] != 0
add_edge!(gr, i, j)
else
nothing
end
end
# Attach the metagraph to the original graph
mgr = MetaDiGraph(gr)
# Add the attribute of nodes
for i in 1:size(mat_arcTwoNodes,1)
set_props!(mgr, i, Dict(
Symbol("vec_xNode") => vec_xNode[i],
Symbol("vec_yNode") => vec_yNode[i]
))
end
# Plot the graph
graphplot(gr, x=vec_xNode, y=vec_yNode)
there is an error:
LoadError: MethodError: no method matching Graphs.SimpleGraphs.SimpleDiGraph(::SimpleDiGraph{Int64})