Skip to content
This repository has been archived by the owner on Oct 21, 2021. It is now read-only.

Error Creating Graph using graph(V,E) #190

Open
onlyhalfwaytrue opened this issue Jun 30, 2015 · 2 comments
Open

Error Creating Graph using graph(V,E) #190

onlyhalfwaytrue opened this issue Jun 30, 2015 · 2 comments

Comments

@onlyhalfwaytrue
Copy link

The vs and es sets are already created with vertices and edges already there. They worked when I created an edgelist graph.

julia> g = graph(vs,es,is_directed=false)
ERROR: make_vertex has no method matching make_vertex(::GenericGraph{Any,Any,Array{Any,1},Array{Any,1},Array{Array{Any,1},1}}, ::KeyVertex{ASCIIString})
in add_vertex! at /Users/ja26144/.julia/v0.3/Graphs.jl/src/graph.jl:100
in graph at /Users/ja26144/.julia/v0.3/Graphs.jl/src/graph.jl:44

@bjmtrk
Copy link

bjmtrk commented Jan 20, 2016

I am having the same problem.

julia> using Graphs

julia> typealias SEdge Edge{AbstractString}
Graphs.Edge{AbstractString}

julia> g = graph(["A","B","C","D"],SEdge[])
Directed Graph (4 vertices, 0 edges)

julia> typeof(g)
Graphs.GenericGraph{ASCIIString,Graphs.Edge{AbstractString},Array{ASCIIString,1},Array{Graphs.Edge{AbstractString},1},Array{Array{Graphs.Edge{AbstractString},1},1}}

julia> eds = [("A", "B"), ("B", "C"), ("C", "A"), ("C", "D")]
4-element Array{Tuple{ASCIIString,ASCIIString},1}:
("A","B")
("B","C")
("C","A")
("C","D")

julia> for (u, v) in eds
add_edge!(g, u, v)
end
ERROR: MethodError: add_edge! has no method matching add_edge!(::Graphs.GenericGraph{ASCIIString,Graphs.Edge{AbstractString},Array{ASCIIString,1},Array{Graphs.Edge{AbstractString},1},Array{Array{Graphs.Edge{AbstractString},1},1}}, ::ASCIIString, ::ASCIIString, ::Graphs.Edge{ASCIIString})
Closest candidates are:
add_edge!{V,E}(::Graphs.GenericIncidenceList{V,E,VList,IncList}, ::V, ::V, ::E)
add_edge!{V,E}(::Graphs.GenericGraph{V,E,VList,EList,IncList}, ::V, ::V, ::E)
add_edge!{V,E}(::Graphs.GenericGraph{V,E,VList,EList,IncList}, ::V, ::V)
...

@weijianzhg
Copy link
Contributor

Hi @bjmtrk,

typealias SEdge Edge{ASCIIString}

will work in your example.

If you check the source,

add_edge!{V,E}(g::GenericGraph{V,E}, u::V, v::V) = add_edge!(g, u, v, make_edge(g, u, v))

This means the nodes and edges must have the same type. In your example, the nodes are ASCIIString but the edges are AbstractString.

KristofferC pushed a commit to KristofferC/Graphs.jl that referenced this issue Oct 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants