Skip to content

Commit 25b9d91

Browse files
gdallematbesancon
andauthored
Move docs from readme to website, better testing (#34)
- Use Documenter to create a documentation website featuring the docstrings and former README tutorial - Add this build step to CI - Test for code quality and formatting (indicated as broken because I didn't want to overload this PR with formatting changes) --------- Co-authored-by: Mathieu Besançon <mathieu.besancon@gmail.com>
1 parent 5a2c8fd commit 25b9d91

File tree

14 files changed

+418
-130
lines changed

14 files changed

+418
-130
lines changed

.JuliaFormatter.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
style = "blue"

.codecov.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/workflows/CI.yml

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
name: CI
2-
env:
3-
JULIA_NUM_THREADS: 2
42
on:
5-
pull_request:
6-
branches:
7-
- master
83
push:
94
branches:
105
- master
11-
tags: '*'
6+
tags: ['*']
7+
pull_request:
8+
concurrency:
9+
# Skip intermediate builds: always.
10+
# Cancel intermediate builds: only if it is a pull request build.
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
1213
jobs:
1314
test:
1415
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
@@ -17,13 +18,11 @@ jobs:
1718
fail-fast: false
1819
matrix:
1920
version:
20-
- 'nightly'
21-
- '1'
2221
- '1.6'
22+
- '1'
23+
- 'nightly'
2324
os:
2425
- ubuntu-latest
25-
- macos-latest
26-
- windows-latest
2726
arch:
2827
- x64
2928
steps:
@@ -32,19 +31,31 @@ jobs:
3231
with:
3332
version: ${{ matrix.version }}
3433
arch: ${{ matrix.arch }}
35-
- uses: actions/cache@v1
36-
env:
37-
cache-name: cache-artifacts
38-
with:
39-
path: ~/.julia/artifacts
40-
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
41-
restore-keys: |
42-
${{ runner.os }}-test-${{ env.cache-name }}-
43-
${{ runner.os }}-test-
44-
${{ runner.os }}-
34+
- uses: julia-actions/cache@v1
4535
- uses: julia-actions/julia-buildpkg@v1
4636
- uses: julia-actions/julia-runtest@v1
4737
- uses: julia-actions/julia-processcoverage@v1
48-
- uses: codecov/codecov-action@v1
38+
- uses: codecov/codecov-action@v2
39+
with:
40+
files: lcov.info
41+
docs:
42+
name: Documentation
43+
runs-on: ubuntu-latest
44+
permissions:
45+
contents: write
46+
statuses: write
47+
steps:
48+
- uses: actions/checkout@v2
49+
- uses: julia-actions/setup-julia@v1
4950
with:
50-
file: lcov.info
51+
version: '1'
52+
- uses: julia-actions/julia-buildpkg@v1
53+
- uses: julia-actions/julia-docdeploy@v1
54+
env:
55+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56+
- run: |
57+
julia --project=docs -e '
58+
using Documenter: DocMeta, doctest
59+
using SimpleWeightedGraphs
60+
DocMeta.setdocmeta!(SimpleWeightedGraphs, :DocTestSetup, :(using SimpleWeightedGraphs); recursive=true)
61+
doctest(SimpleWeightedGraphs)'

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
*.jl.cov
22
*.jl.*.cov
33
*.jl.mem
4-
Manifest.toml
4+
/Manifest.toml
5+
docs/build/

CITATION.bib

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@misc{SimpleWeightedGraphs.jl,
2+
author = {JuliaGraphs contributors},
3+
title = {SimpleWeightedGraphs.jl},
4+
url = {https://github.com/JuliaGraphs/SimpleWeightedGraphs.jl},
5+
version = {v1.3.0},
6+
year = {2023},
7+
month = {2}
8+
}

Project.toml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
11
name = "SimpleWeightedGraphs"
22
uuid = "47aef6b3-ad0c-573a-a1e2-d07658019622"
3+
authors = ["JuliaGraphs contributors"]
34
version = "1.3.0"
45

56
[deps]
67
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
78
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
89
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
910
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
10-
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1111

1212
[compat]
1313
Graphs = "1.7"
1414
julia = "1"
15+
16+
[extras]
17+
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
18+
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
19+
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
20+
JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
21+
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
22+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
23+
24+
[targets]
25+
test = ["Aqua", "Documenter", "Graphs", "JuliaFormatter", "LinearAlgebra", "Test"]

README.md

Lines changed: 6 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,11 @@
11
# SimpleWeightedGraphs
22

3+
[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://JuliaGraphs.github.io/SimpleWeightedGraphs.jl/stable/)
4+
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://JuliaGraphs.github.io/SimpleWeightedGraphs.jl/dev/)
35
[![Build Status](https://github.com/JuliaGraphs/SimpleWeightedGraphs.jl/actions/workflows/CI.yml/badge.svg?branch=master)](https://github.com/JuliaGraphs/SimpleWeightedGraphs.jl/actions/workflows/CI.yml?query=branch%3Amaster)
4-
[![codecov.io](http://codecov.io/github/JuliaGraphs/SimpleWeightedGraphs.jl/coverage.svg?branch=master)](http://codecov.io/github/JuliaGraphs/SimpleWeightedGraphs.jl?branch=master)
6+
[![Coverage](https://codecov.io/gh/JuliaGraphs/SimpleWeightedGraphs.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/JuliaGraphs/SimpleWeightedGraphs.jl)
7+
[![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle)
58

6-
Edge-Weighted Graphs for [Graphs.jl](https://github.com/JuliaGraphs/Graphs.jl).
9+
Edge-weighted graphs compatible with [Graphs.jl](https://github.com/JuliaGraphs/Graphs.jl).
710

8-
Usage:
9-
```julia
10-
using Graphs, SimpleWeightedGraphs
11-
12-
g = SimpleWeightedGraph(3) # or use `SimpleWeightedDiGraph` for directed graphs
13-
add_edge!(g, 1, 2, 0.5)
14-
add_edge!(g, 2, 3, 0.8)
15-
add_edge!(g, 1, 3, 2.0)
16-
17-
# get weight of edge from vertex 1 to vertex 2
18-
get_weight(g, 1, 2)
19-
20-
# find the shortest path from vertex 1 to vertex 3 taking weights into account.
21-
enumerate_paths(dijkstra_shortest_paths(g, 1), 3)
22-
3-element Array{Int64,1}:
23-
1
24-
2
25-
3
26-
27-
# reweight the edge from 1 to 2
28-
add_edge!(g, 1, 2, 1.6)
29-
30-
# rerun the shortest path calculation from 1 to 3
31-
enumerate_paths(dijkstra_shortest_paths(g, 1), 3)
32-
2-element Array{Int64,1}:
33-
1
34-
3
35-
36-
# it's possible to build the graph from arrays of sources, destinations and weights
37-
sources = [1,2,1]
38-
destinations = [2,3,3]
39-
weights = [0.5, 0.8, 2.0]
40-
g = SimpleWeightedGraph(sources, destinations, weights)
41-
42-
# the combine keyword handles repeated pairs (sum by default)
43-
g = SimpleWeightedGraph([1,2,1], [2,1,2], [1,1,1]; combine = +)
44-
g.weights[2,1] == g.weights[1,2] == 3 # true
45-
46-
# WARNING: unexpected results might occur with non-associative combine functions
47-
48-
# notice that weights are indexed by [destination, source]
49-
s = SimpleWeightedDiGraph([1,2,1], [2,1,2], [1,1,1]; combine = +)
50-
s.weights[1,2] == 1 # true
51-
s.weights[2,1] == 2 # true
52-
```
53-
54-
Please pay attention to the fact that zero-weight edges are discarded by `add_edge!`.
55-
This is due to the way the graph is stored (a sparse matrix). [A possible workaround
56-
is to set a very small weight instead](https://stackoverflow.com/questions/48977068/how-to-add-free-edge-to-graph-in-lightgraphs-julia/48994712#48994712).
57-
58-
Note that adding or removing vertices or edges from these graph types is not particularly performant;
59-
see [MetaGraphs.jl](https://github.com/JuliaGraphs/MetaGraphs.jl) for possible alternatives.
11+
See the [documentation](https://JuliaGraphs.github.io/SimpleWeightedGraphs.jl/dev/) for a tutorial.

appveyor.yml

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)