# Simple DiGraph Plot Directed Graph: no method matching

**URL:** <https://discourse.julialang.org/t/simple-digraph-plot-directed-graph-no-method-matching/94721>\
**Category:** General Usage\
**Tags:** package\
**Created:** [February 16, 2023, 12:38pm UTC](https://discourse.julialang.org/t/simple-digraph-plot-directed-graph-no-method-matching/94721 "2023-02-16T12:38:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Freya\_the\_Goddess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freya_the_goddess/32/36835_2.png) [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Post date:** [February 16, 2023, 12:38pm UTC](https://discourse.julialang.org/t/simple-digraph-plot-directed-graph-no-method-matching/94721/1 "2023-02-16T12:38:16Z")

</div>

Hi all,

I am reading this post:

> <https://stackoverflow.com/questions/55228773/plot-the-directed-graph-in-julia-with-vertices-in-fixed-positions-by-x-y-coordin>

but when I try the code:

```julia
# 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})**

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [February 16, 2023, 1:04pm UTC](https://discourse.julialang.org/t/simple-digraph-plot-directed-graph-no-method-matching/94721/2 "2023-02-16T13:04:16Z")

</div>

Try using Graphs.jl rather than LightGraphs.jl.

Stackoverflow answers sometimes get out of date - since that answer was written, LightGraphs.jl has been discontinued in favour of Graphs.jl.

With that change, the graph construction code works for me.

---

<div class="post-metadata">

**Author:** ![Freya\_the\_Goddess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freya_the_goddess/32/36835_2.png) [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Post date:** [February 16, 2023, 2:14pm UTC](https://discourse.julialang.org/t/simple-digraph-plot-directed-graph-no-method-matching/94721/3 "2023-02-16T14:14:44Z")

</div>

Yes, I think SoF is not as updated as Julia Discourse. This forum is really handy and fast.
