Skip to content

Error messages with MetaGraph, vertices, and edges #8

Closed
@ljournot

Description

Hi
I get a number of problems with MetaGraphs.

  1. The MetaGraph function of MetaGraphs does not convert a SimpleGraph to a MetaGraph. The error message refers to LightGraphs, which I uninstalled (rm LightGraphs) before adding Graphs.
  2. The vertices function works on a SimpleGraph and does not on a MetaGraph -> no method matching...
  3. The edges function works on a SimpleGraph and does not on a MetaGraph -> edges function not implemented

Any help is welcome.
Laurent
PS: I am a biologist not very well skilled at Julia and programing in general.

julia> using Graphs, MetaGraphs, DataFrames, GraphDataFrameBridge

julia> g=complete_graph(3)
{3, 3} undirected simple Int64 graph

julia> mg=MetaGraphs.MetaGraph(g)
ERROR: MethodError: no method matching LightGraphs.SimpleGraphs.SimpleGraph(::SimpleGraph{Int64})
Closest candidates are:
  LightGraphs.SimpleGraphs.SimpleGraph(::Any, ::Array{Vector{T}, 1}) where T at C:\Users\Laurent\.julia\packages\LightGraphs\IgJif\src\SimpleGraphs\simplegraph.jl:18
  LightGraphs.SimpleGraphs.SimpleGraph() at C:\Users\Laurent\.julia\packages\LightGraphs\IgJif\src\SimpleGraphs\simplegraph.jl:50
  LightGraphs.SimpleGraphs.SimpleGraph(::MetaGraph) at C:\Users\Laurent\.julia\packages\MetaGraphs\UlMik\src\metagraph.jl:50
  ...
Stacktrace:
 [1] MetaGraph(x::SimpleGraph{Int64}, weightfield::Symbol, defaultweight::Float64)
   @ MetaGraphs ~\.julia\packages\MetaGraphs\UlMik\src\metagraph.jl:14
 [2] MetaGraph(x::SimpleGraph{Int64})
   @ MetaGraphs ~\.julia\packages\MetaGraphs\UlMik\src\metagraph.jl:26
 [3] top-level scope
   @ REPL[20]:1

julia> df = DataFrame(src=["g1", "g2", "g3"], dst=["g2", "g3", "g1"], weight=[1, 1 ,1])
3×3 DataFrame
 Row │ src     dst     weight
     │ String  String  Int64
─────┼────────────────────────
   1 │ g1      g2           1
   2 │ g2      g3           1
   3 │ g3      g1           1

julia> mg=GraphDataFrameBridge.MetaGraph(df, :src, :dst, weight=:weight)
{3, 3} undirected Int64 metagraph with Float64 weights defined by :weight (default weight 1.0)

julia> vertices(mg)
ERROR: MethodError: no method matching vertices(::MetaGraph{Int64, Float64})
Closest candidates are:
  vertices(::Graphs.SimpleGraphs.AbstractSimpleGraph) at C:\Users\Laurent\.julia\packages\Graphs\Mih78\src\SimpleGraphs\SimpleGraphs.jl:58
  vertices(::AbstractGraph) at C:\Users\Laurent\.julia\packages\Graphs\Mih78\src\interface.jl:181
Stacktrace:
 [1] top-level scope
   @ REPL[23]:1

julia> vertices(g)
Base.OneTo(3)

julia> edges(mg)
ERROR: method edges not implemented.
Stacktrace:
 [1] _NI(m::String)
   @ Graphs ~\.julia\packages\Graphs\Mih78\src\interface.jl:16
 [2] edges(g::MetaGraph{Int64, Float64})
   @ Graphs ~\.julia\packages\Graphs\Mih78\src\interface.jl:207
 [3] top-level scope
   @ REPL[25]:1

julia> edges(g)
SimpleEdgeIter 3

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions