1

I am trying to create a simple type of Graph before putting more efforts on the bigger one I will have to create with data implementation and I figured out that add_vertex! was exactly what I needed to add a special type of vertex into my graph. Here is the simple example I tried and I get the reply that add_vertex! is not defined..

module VSRPGraphModule    

using Graphs, LightGraphs, MetaGraphs

g = DiGraph()
println(g)

v=ExVertex(1,"ex")
port=VSRPPort()
FillPort(port,"La Havane",10)
v.attributes["port"]=port
println(v.attributes["port"].name)
add_vertex!(g,v)
println(g)

end

And the codes stops at the add_vertex! line returning:

LoadError: UndefVarError: add_vertex! not defined

I did Pkg.update()

I did put the package into julia.

I really don't know why it is not working, is it a problem of the new Julia version 0.6.9 ?

Thanks in advance for your help !

Alexo
  • 49
  • 7

1 Answers1

1

tl;dr Try just using LightGraphs + MetaGraphs (not Graphs).

LightGraphs and Graphs are separate packages and I don't think they work together. IIRC Graphs is no longer maintained so if you can then just use LightGraphs.


Regardless, if you try to use two packages that export the same method (add_vertex!) you'll need to specify which one you want to call.

e.g. Graphs.add_vertex! or LightGraphs.add_vertex!.

Alexander Morley
  • 4,111
  • 12
  • 26
  • Thanks! It was the Graphs.add_vertex! specification that solved the issue. Concerning the maintenance of the Graphs package, do you think it will be maintained in the future or is it obsolete for the versions to come? I used this package in the end for my code because it had better functionalities for my problem like the ExVertex type. – Alexo Feb 07 '18 at 16:55
  • Impossible to know. As 1.0 should be released soon it will likely be obvious by the end of the year what will happen. My guess is that any remaining functionality will be ported to `LightGraphs` or another package from that ecosystem at some point. – Alexander Morley Feb 07 '18 at 17:19
  • Also if this answered your question please accept/upvote :) – Alexander Morley Feb 07 '18 at 17:19
  • Hi, I'm the primary author of LightGraphs / MetaGraphs. The accepted answer is correct, but I wanted to give you some more insight. Graphs.jl should, IMO, not be used for anything new. It's a legacy package that has some maintainers who are focused on ensuring that it works on the latest versions of Julia, but no real new development has occurred there for some time. If you have questions about LightGraphs/MetaGraphs, we'd be happy to help - you can file an issue, ask on the Julia discourse site, or join us on slack. – sbromberger Feb 14 '18 at 00:20