Skip to content

Commit fbde6c3

Browse files
authored
Merge pull request #40 from storopoli/move-Graphs
Move From LightGraphs.jl to Graphs.jl
2 parents eb35fe3 + 1cc29c8 commit fbde6c3

File tree

20 files changed

+184
-114
lines changed

20 files changed

+184
-114
lines changed

.github/workflows/CompatHelper.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: CompatHelper
2+
3+
on:
4+
schedule:
5+
- cron: 0 * * * *
6+
7+
jobs:
8+
CompatHelper:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Pkg.add("CompatHelper")
12+
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
13+
- name: CompatHelper.main()
14+
env:
15+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16+
run: julia -e 'using CompatHelper; CompatHelper.main()'

.github/workflows/TagBot.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: TagBot
2+
on:
3+
schedule:
4+
- cron: 30 * * * *
5+
workflow_dispatch:
6+
jobs:
7+
TagBot:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: JuliaRegistries/TagBot@v1
11+
with:
12+
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/ci.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: CI
2+
on:
3+
pull_request:
4+
branches:
5+
- master
6+
push:
7+
branches:
8+
- master
9+
tags: '*'
10+
jobs:
11+
test:
12+
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
version:
18+
- '1'
19+
os:
20+
- ubuntu-latest
21+
arch:
22+
- x64
23+
steps:
24+
- uses: actions/checkout@v2
25+
- uses: julia-actions/setup-julia@v1
26+
with:
27+
version: ${{ matrix.version }}
28+
arch: ${{ matrix.arch }}
29+
- uses: actions/cache@v1
30+
env:
31+
cache-name: cache-artifacts
32+
with:
33+
path: ~/.julia/artifacts
34+
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
35+
restore-keys: |
36+
${{ runner.os }}-test-${{ env.cache-name }}-
37+
${{ runner.os }}-test-
38+
${{ runner.os }}-
39+
- uses: julia-actions/julia-buildpkg@v1
40+
- uses: julia-actions/julia-runtest@v1
41+
- uses: julia-actions/julia-processcoverage@v1
42+
- uses: codecov/codecov-action@v1
43+
with:
44+
file: lcov.info

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
.DS_Store
12
*.jl.cov
2-
*.jl.*.cov
33
*.jl.mem
4+
.vscode
5+
docs/build/
6+
docs/site/
7+
benchmark/.results/*
8+
benchmark/.tune.jld
9+
*.cov
10+
Manifest.toml

Project.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
name = "GraphIO"
22
uuid = "aa1b3936-2fda-51b9-ab35-c553d3a640a2"
3-
version = "0.5.0"
3+
version = "0.6.0"
44

55
[deps]
66
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
7-
LightGraphs = "093fc24a-ae57-5d10-9952-331d41423f4d"
7+
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
88
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
99
SimpleTraits = "699a6c99-e7fa-54fc-8d76-47d257e15c1d"
1010

1111
[compat]
1212
EzXML = "1"
13-
LightGraphs = "1"
14-
ParserCombinator = "2"
15-
julia = "1"
13+
Graphs = "1.4"
14+
ParserCombinator = "2.1"
1615
Requires = "1"
1716
SimpleTraits = "0.9"
17+
julia = "1"
1818

1919
[extras]
2020
CodecZlib = "944b1d66-785c-5afd-91f1-9de20f533193"
2121
EzXML = "8f5d6c58-4d21-5cfd-889c-e3ad7ee6a615"
22-
LightGraphs = "093fc24a-ae57-5d10-9952-331d41423f4d"
22+
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
2323
ParserCombinator = "fae87a5f-d1ad-5cf0-8f61-c941e1580b46"
2424
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2525

2626
[targets]
27-
test = ["CodecZlib", "LightGraphs", "EzXML", "ParserCombinator", "Test"]
27+
test = ["CodecZlib", "Graphs", "EzXML", "ParserCombinator", "Test"]

README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
# GraphIO
22

3-
[![Build Status](https://travis-ci.org/JuliaGraphs/GraphIO.jl.svg?branch=master)](https://travis-ci.org/JuliaGraphs/GraphIO.jl)
3+
[![Build Status](https://github.com/JuliaGraphs/GraphIO.jl/workflows/CI/badge.svg)](https://github.com/JuliaGraphs/GraphIO.jl/actions?query=workflow%3ACI+branch%3Amaster)
44
[![codecov.io](http://codecov.io/github/JuliaGraphs/GraphIO.jl/coverage.svg?branch=master)](http://codecov.io/github/JuliaGraphs/GraphIO.jl?branch=master)
55

6-
GraphIO provides support to [LightGraphs.jl](https://github.com/JuliaGraphs/LightGraphs.jl) for reading/writing graphs in various formats.
7-
8-
The current version of GraphIO works with Julia version >= 0.7.
6+
GraphIO provides support to [Graphs.jl](https://github.com/JuliaGraphs/Graphs.jl) for reading/writing graphs in various formats.
97

108
Currently, the following functionality is provided:
119

@@ -29,11 +27,11 @@ Format | Read | Write | Multiple Graphs| Format Name |
2927
[DOT]: https://en.wikipedia.org/wiki/DOT_(graph_description_language)
3028

3129
Graphs are read using either the `loadgraph` function or, for formats that support multiple graphs in a single file,
32-
the `loadgraphs` functions. `loadgraph` returns a LightGraph object, while `loadgraphs` returns a dictionary of LightGraph objects.
30+
the `loadgraphs` functions. `loadgraph` returns a Graph object, while `loadgraphs` returns a dictionary of Graph objects.
3331

3432
For example, an edgelist file could be loaded as:
3533

36-
```
34+
```julia
3735
graph = loadgraph("path_to_graph/my_edgelist.txt", "graph_key", EdgeListFormat())
3836
```
3937

src/CDF/Cdf.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ module CDF
44
# http://www2.ee.washington.edu/research/pstca/formats/cdf.txt
55
# http://www2.ee.washington.edu/research/pstca/pf30/ieee30cdf.txt
66

7-
using LightGraphs
8-
using LightGraphs: AbstractGraphFormat
7+
using Graphs
8+
using Graphs: AbstractGraphFormat
99

10-
import LightGraphs: loadgraph, loadgraphs, savegraph
10+
import Graphs: loadgraph, loadgraphs, savegraph
1111

1212
export CDFFormat
1313

@@ -45,7 +45,7 @@ function _loadcdf(io::IO)
4545
end
4646
end
4747
n_v = length(vertices)
48-
g = LightGraphs.Graph(n_v)
48+
g = Graphs.Graph(n_v)
4949
for p in zip(srcs, dsts)
5050
add_edge!(g, p)
5151
end

src/DOT/Dot.jl

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
module DOT
22

33
using GraphIO.ParserCombinator.Parsers
4-
using LightGraphs
5-
using LightGraphs: AbstractGraphFormat
4+
using Graphs
5+
using Graphs: AbstractGraphFormat
66

7-
import LightGraphs: loadgraph, loadgraphs, savegraph
7+
import Graphs: loadgraph, loadgraphs, savegraph
88

99
export DOTFormat
1010

1111
struct DOTFormat <: AbstractGraphFormat end
1212

13-
function savedot(io::IO, g::LightGraphs.AbstractGraph, gname::String = "")
14-
isdir = LightGraphs.is_directed(g)
13+
function savedot(io::IO, g::Graphs.AbstractGraph, gname::String = "")
14+
isdir = Graphs.is_directed(g)
1515
println(io,(isdir ? "digraph " : "graph ") * gname * " {")
16-
for i in LightGraphs.vertices(g)
16+
for i in Graphs.vertices(g)
1717
println(io,"\t" * string(i))
1818
end
1919
if isdir
20-
for u in LightGraphs.vertices(g)
21-
out_nbrs = LightGraphs.outneighbors(g, u)
20+
for u in Graphs.vertices(g)
21+
out_nbrs = Graphs.outneighbors(g, u)
2222
length(out_nbrs) == 0 && continue
2323
println(io, "\t" * string(u) * " -> {" * join(out_nbrs,',') * "}")
2424
end
2525
else
26-
for e in LightGraphs.edges(g)
27-
source = string(LightGraphs.src(e))
28-
dest = string(LightGraphs.dst(e))
26+
for e in Graphs.edges(g)
27+
source = string(Graphs.src(e))
28+
dest = string(Graphs.dst(e))
2929
println(io, "\t" * source * " -- " * dest)
3030
end
3131
end
@@ -46,9 +46,9 @@ function _dot_read_one_graph(pg::Parsers.DOT.Graph)
4646
nvg = length(Parsers.DOT.nodes(pg))
4747
nodedict = Dict(zip(collect(Parsers.DOT.nodes(pg)), 1:nvg))
4848
if isdir
49-
g = LightGraphs.DiGraph(nvg)
49+
g = Graphs.DiGraph(nvg)
5050
else
51-
g = LightGraphs.Graph(nvg)
51+
g = Graphs.Graph(nvg)
5252
end
5353
for es in Parsers.DOT.edges(pg)
5454
s = nodedict[es[1]]
@@ -58,27 +58,24 @@ function _dot_read_one_graph(pg::Parsers.DOT.Graph)
5858
return g
5959
end
6060

61+
_name(pg::Parsers.DOT.Graph) =
62+
pg.id !== nothing ? pg.id.id :
63+
Parsers.DOT.StringID(pg.directed ? "digraph" : "graph")
64+
6165
function loaddot(io::IO, gname::String)
6266
p = Parsers.DOT.parse_dot(read(io, String))
6367
for pg in p
64-
isdir = pg.directed
65-
possname = isdir ? Parsers.DOT.StringID("digraph") : Parsers.DOT.StringID("graph")
66-
name = get(pg.id, possname).id
67-
name == gname && return _dot_read_one_graph(pg)
68+
_name(pg) == gname && return _dot_read_one_graph(pg)
6869
end
6970
error("Graph $gname not found")
7071
end
7172

7273
function loaddot_mult(io::IO)
7374
p = Parsers.DOT.parse_dot(read(io, String))
74-
7575
graphs = Dict{String,AbstractGraph}()
7676

7777
for pg in p
78-
isdir = pg.directed
79-
possname = isdir ? Parsers.DOT.StringID("digraph") : Parsers.DOT.StringID("graph")
80-
name = get(pg.id, possname).id
81-
graphs[name] = _dot_read_one_graph(pg)
78+
graphs[_name(pg)] = _dot_read_one_graph(pg)
8279
end
8380
return graphs
8481
end

src/Edgelist/Edgelist.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ module EdgeList
55
# each line. Will return a directed graph.
66

77
using DelimitedFiles: writedlm
8-
using LightGraphs
9-
using LightGraphs: AbstractGraphFormat
8+
using Graphs
9+
using Graphs: AbstractGraphFormat
1010

11-
import LightGraphs: loadgraph, loadgraphs, savegraph
11+
import Graphs: loadgraph, loadgraphs, savegraph
1212

1313
export EdgeListFormat
1414

@@ -36,15 +36,15 @@ function loadedgelist(io::IO, gname::String)
3636
end
3737

3838
n_v = length(vxset)
39-
g = LightGraphs.DiGraph(n_v)
39+
g = Graphs.DiGraph(n_v)
4040
for (u, v) in zip(srcs, dsts)
4141
add_edge!(g, vxdict[u], vxdict[v])
4242
end
4343
return g
4444
end
4545

46-
function saveedgelist(io::IO, g::LightGraphs.AbstractGraph, gname::String)
47-
writedlm(io, ([src(e), dst(e)] for e in LightGraphs.edges(g)), ',')
46+
function saveedgelist(io::IO, g::Graphs.AbstractGraph, gname::String)
47+
writedlm(io, ([src(e), dst(e)] for e in Graphs.edges(g)), ',')
4848
return 1
4949
end
5050

src/Edgelist/IntEdgeList.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function loadintedgelist(io::IO, gname::String, offset::Int64)
4040
push!(badjlist[v], u)
4141
end
4242
end
43-
return LightGraphs.DiGraph(neg, fadjlist, badjlist)
43+
return Graphs.DiGraph(neg, fadjlist, badjlist)
4444
end
4545

4646
loadgraph(io::IO, gname::String, fmt::IntEdgeListFormat) = loadintedgelist(io, gname, fmt.offset)

src/GEXF/Gexf.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
module GEXF
22

33
using GraphIO.EzXML
4-
using LightGraphs
5-
using LightGraphs: AbstractGraph, AbstractGraphFormat
4+
using Graphs
5+
using Graphs: AbstractGraph, AbstractGraphFormat
66

7-
import LightGraphs: savegraph
7+
import Graphs: savegraph
88

99
export GEXFFormat
1010

@@ -16,7 +16,7 @@ struct GEXFFormat <: AbstractGraphFormat end
1616
Write a graph `g` with name `gname` to an IO stream `io` in the
1717
[Gexf](http://gexf.net/format/) format. Return 1 (number of graphs written).
1818
"""
19-
function savegexf(io::IO, g::LightGraphs.AbstractGraph, gname::String)
19+
function savegexf(io::IO, g::Graphs.AbstractGraph, gname::String)
2020
xdoc = XMLDocument()
2121
xroot = setroot!(xdoc, ElementNode("gexf"))
2222
xroot["xmlns"] = "http://www.gexf.net/1.2draft"
@@ -38,7 +38,7 @@ function savegexf(io::IO, g::LightGraphs.AbstractGraph, gname::String)
3838

3939
xedges = addelement!(xg, "edges")
4040
m = 0
41-
for e in LightGraphs.edges(g)
41+
for e in Graphs.edges(g)
4242
xe = addelement!(xedges, "edge")
4343
xe["id"] = "$m"
4444
xe["source"] = "$(src(e)-1)"

src/GML/Gml.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
module GML
22

33
using GraphIO.ParserCombinator.Parsers
4-
using LightGraphs
5-
using LightGraphs: AbstractGraphFormat
4+
using Graphs
5+
using Graphs: AbstractGraphFormat
66

7-
import LightGraphs: loadgraph, loadgraphs, savegraph
7+
import Graphs: loadgraph, loadgraphs, savegraph
88

99
export GMLFormat
1010

@@ -14,9 +14,9 @@ struct GMLFormat <: AbstractGraphFormat end
1414
function _gml_read_one_graph(gs, dir)
1515
nodes = [x[:id] for x in gs[:node]]
1616
if dir
17-
g = LightGraphs.DiGraph(length(nodes))
17+
g = Graphs.DiGraph(length(nodes))
1818
else
19-
g = LightGraphs.Graph(length(nodes))
19+
g = Graphs.Graph(length(nodes))
2020
end
2121
mapping = Dict{Int,Int}()
2222
for (i, n) in enumerate(nodes)
@@ -42,7 +42,7 @@ end
4242

4343
function loadgml_mult(io::IO)
4444
p = Parsers.GML.parse_dict(read(io, String))
45-
graphs = Dict{String,LightGraphs.AbstractGraph}()
45+
graphs = Dict{String,Graphs.AbstractGraph}()
4646
for gs in p[:graph]
4747
dir = Bool(get(gs, :directed, 0))
4848
graphname = get(gs, :label, dir ? "digraph" : "graph")
@@ -57,7 +57,7 @@ end
5757
Write a graph `g` with name `gname` to an IO stream `io` in the
5858
[GML](https://en.wikipedia.org/wiki/Graph_Modelling_Language) format. Return 1.
5959
"""
60-
function savegml(io::IO, g::LightGraphs.AbstractGraph, gname::String = "")
60+
function savegml(io::IO, g::Graphs.AbstractGraph, gname::String = "")
6161
println(io, "graph")
6262
println(io, "[")
6363
length(gname) > 0 && println(io, "label \"$gname\"")
@@ -68,7 +68,7 @@ function savegml(io::IO, g::LightGraphs.AbstractGraph, gname::String = "")
6868
println(io, "\t\tid $i")
6969
println(io, "\t]")
7070
end
71-
for e in LightGraphs.edges(g)
71+
for e in Graphs.edges(g)
7272
s, t = Tuple(e)
7373
println(io, "\tedge")
7474
println(io, "\t[")

0 commit comments

Comments
 (0)