Skip to content

Commit

Permalink
Migrate from LightGraphs to Graphs.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
simonschoelly committed Oct 16, 2021
1 parent c14d2e8 commit 4e64abe
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 23 deletions.
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
name = "MetaGraphs"
uuid = "626554b9-1ddb-594c-aa3c-2596fe9399a5"
version = "0.6.8"
version = "0.7.0"

[deps]
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
LightGraphs = "093fc24a-ae57-5d10-9952-331d41423f4d"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[compat]
Graphs = "1.4"
JLD2 = "0.1.11, 0.2, 0.3, 0.4"
LightGraphs = "1.3.5"
julia = "1"

[extras]
Expand Down
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
[![Codecov branch][codecov-img]][codecov-url]
[![](https://img.shields.io/badge/docs-latest-blue.svg)](https://juliagraphs.github.io/MetaGraphs.jl/latest)

**Project Status:** As of 8 October 2021 MetaGraphs is no longer under active development. It will remain available on Github at [sbromberger/MetaGraphs.jl](/~https://github.com/sbromberger/MetaGraphs.jl). The JuliaGraphs organization will continue to maintain packages that use MetaGraphs and transition development over the long term.

[LightGraphs.jl](/~https://github.com/JuliaGraphs/LightGraphs.jl) graphs with arbitrary metadata.
[MetaGraphs.jl](/~https://github.com/JuliaGraphs/MetaGraphs.jl) graphs with arbitrary metadata.

[build-img]: /~https://github.com/JuliaGraphs/Metagraphs.jl/workflows/CI/badge.svg?branch=master
[build-url]: /~https://github.com/JuliaGraphs/Metagraphs.jl/actions?query=workflow%3ACI
Expand All @@ -25,7 +23,7 @@ add MetaGraphs

## Example Usage
```julia
julia> using LightGraphs, MetaGraphs
julia> using Graphs, MetaGraphs

# create a standard simplegraph
julia> g = path_graph(5)
Expand Down Expand Up @@ -87,7 +85,7 @@ Dict{Symbol,Any} with 0 entries
julia> props(mg, 2)
Dict{Symbol,Any} with 0 entries

# all LightGraphs analytics work
# all Graphs.jl analytics work
julia> betweenness_centrality(mg)
5-element Array{Float64,1}:
0.0
Expand Down
2 changes: 1 addition & 1 deletion docs/oldmkdocsyml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
site_name: MetaGraphs.jl
repo_url: /~https://github.com/JuliaGraphs/MetaGraphs.jl
site_description: Metadata for LightGraphs
site_description: Metadata for Graphs.jl
site_author: Seth Bromberger

theme: readthedocs
Expand Down
8 changes: 4 additions & 4 deletions src/MetaGraphs.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module MetaGraphs
using LightGraphs
using Graphs
using JLD2

import Base:
Expand All @@ -9,7 +9,7 @@ import Base:
import Random:
randstring, seed!

import LightGraphs:
import Graphs:
AbstractGraph, src, dst, edgetype, nv,
ne, vertices, edges, is_directed,
add_vertex!, add_edge!, rem_vertex!, rem_edge!,
Expand All @@ -19,7 +19,7 @@ import LightGraphs:
loadgraph, savegraph, AbstractGraphFormat,
reverse

import LightGraphs.SimpleGraphs:
import Graphs.SimpleGraphs:
AbstractSimpleGraph, SimpleGraph, SimpleDiGraph,
SimpleEdge, fadj, badj

Expand Down Expand Up @@ -194,7 +194,7 @@ MetaWeights(g::AbstractMetaGraph) = MetaWeights{eltype(g),eltype(g.defaultweight

function getindex(w::MetaWeights{T,U}, u::Integer, v::Integer)::U where T <: Integer where U <: Real
_e = Edge(u, v)
e = !w.directed && !LightGraphs.is_ordered(_e) ? reverse(_e) : _e
e = !w.directed && !Graphs.is_ordered(_e) ? reverse(_e) : _e
!haskey(w.eprops, e) && return w.defaultweight
return U(get(w.eprops[e], w.weightfield, w.defaultweight))
end
Expand Down
4 changes: 2 additions & 2 deletions src/metagraph.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ is_directed(g::MetaGraph) = false

weighttype(g::MetaGraph{T,U}) where T where U = U
function props(g::MetaGraph, _e::SimpleEdge)
e = LightGraphs.is_ordered(_e) ? _e : reverse(_e)
e = Graphs.is_ordered(_e) ? _e : reverse(_e)
get(PropDict, g.eprops, e)
end

function set_props!(g::MetaGraph, _e::SimpleEdge, d::Dict)
e = LightGraphs.is_ordered(_e) ? _e : reverse(_e)
e = Graphs.is_ordered(_e) ? _e : reverse(_e)
if has_edge(g, e)
if !_hasdict(g, e)
g.eprops[e] = d
Expand Down
2 changes: 1 addition & 1 deletion test/dotformat.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using MetaGraphs
using Test
using LightGraphs
using Graphs

property_set=[
(src="thirty",dst="inf",color="missing",penwidth="missing",style="missing",),
Expand Down
10 changes: 5 additions & 5 deletions test/metagraphs.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using MetaGraphs
import LightGraphs: SimpleGraphs
import Graphs: SimpleGraphs
import Base64:
stringmime

Expand Down Expand Up @@ -32,8 +32,8 @@ import Base64:
@test eltype(@inferred(MetaGraph{UInt8,Float16}(mg))) == UInt8
@test weighttype(@inferred(MetaGraph{UInt8,Float16}(mg))) == Float16

@test @inferred(MetaGraphs.fadj(mg, 2)) == LightGraphs.SimpleGraphs.fadj(g, 2)
@test @inferred(MetaGraphs.badj(mg, 2)) == LightGraphs.SimpleGraphs.badj(g, 2)
@test @inferred(MetaGraphs.fadj(mg, 2)) == Graphs.SimpleGraphs.fadj(g, 2)
@test @inferred(MetaGraphs.badj(mg, 2)) == Graphs.SimpleGraphs.badj(g, 2)

@test @inferred(edgetype(mg)) == edgetype(mg.graph)

Expand Down Expand Up @@ -88,8 +88,8 @@ import Base64:
@test eltype(@inferred(MetaDiGraph{UInt8,Float16}(mg))) == UInt8
@test weighttype(@inferred(MetaDiGraph{UInt8,Float16}(mg))) == Float16

@test @inferred(MetaGraphs.fadj(mg, 2)) == LightGraphs.SimpleGraphs.fadj(g, 2)
@test @inferred(MetaGraphs.badj(mg, 2)) == LightGraphs.SimpleGraphs.badj(g, 2)
@test @inferred(MetaGraphs.fadj(mg, 2)) == Graphs.SimpleGraphs.fadj(g, 2)
@test @inferred(MetaGraphs.badj(mg, 2)) == Graphs.SimpleGraphs.badj(g, 2)

@test @inferred(edgetype(mg)) == edgetype(mg.graph)

Expand Down
4 changes: 2 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using LightGraphs
using Graphs
using MetaGraphs
using Test

import LightGraphs.SimpleGraphs: SimpleGraph, SimpleDiGraph
import Graphs.SimpleGraphs: SimpleGraph, SimpleDiGraph

const testdir = @__DIR__

Expand Down

0 comments on commit 4e64abe

Please sign in to comment.