-
Notifications
You must be signed in to change notification settings - Fork 8
Move docs from readme to website, better testing #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| style = "blue" |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| *.jl.cov | ||
| *.jl.*.cov | ||
| *.jl.mem | ||
| Manifest.toml | ||
| /Manifest.toml | ||
| docs/build/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| @misc{SimpleWeightedGraphs.jl, | ||
| author = {JuliaGraphs contributors}, | ||
| title = {SimpleWeightedGraphs.jl}, | ||
| url = {https://github.com/JuliaGraphs/SimpleWeightedGraphs.jl}, | ||
| version = {v1.3.0}, | ||
| year = {2023}, | ||
| month = {2} | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,25 @@ | ||
| name = "SimpleWeightedGraphs" | ||
| uuid = "47aef6b3-ad0c-573a-a1e2-d07658019622" | ||
| authors = ["JuliaGraphs contributors"] | ||
| version = "1.3.0" | ||
|
|
||
| [deps] | ||
| Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6" | ||
| LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" | ||
| Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a" | ||
| SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" | ||
| Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
|
|
||
| [compat] | ||
| Graphs = "1.7" | ||
| julia = "1" | ||
|
|
||
| [extras] | ||
| Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" | ||
| Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" | ||
| Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6" | ||
| JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899" | ||
| LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" | ||
| Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
|
|
||
| [targets] | ||
| test = ["Aqua", "Documenter", "Graphs", "JuliaFormatter", "LinearAlgebra", "Test"] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,59 +1,11 @@ | ||
| # SimpleWeightedGraphs | ||
|
|
||
| [](https://JuliaGraphs.github.io/SimpleWeightedGraphs.jl/stable/) | ||
| [](https://JuliaGraphs.github.io/SimpleWeightedGraphs.jl/dev/) | ||
| [](https://github.com/JuliaGraphs/SimpleWeightedGraphs.jl/actions/workflows/CI.yml?query=branch%3Amaster) | ||
| [](http://codecov.io/github/JuliaGraphs/SimpleWeightedGraphs.jl?branch=master) | ||
| [](https://codecov.io/gh/JuliaGraphs/SimpleWeightedGraphs.jl) | ||
| [](https://github.com/invenia/BlueStyle) | ||
|
|
||
| Edge-Weighted Graphs for [Graphs.jl](https://github.com/JuliaGraphs/Graphs.jl). | ||
| Edge-weighted graphs compatible with [Graphs.jl](https://github.com/JuliaGraphs/Graphs.jl). | ||
|
|
||
| Usage: | ||
| ```julia | ||
| using Graphs, SimpleWeightedGraphs | ||
|
|
||
| g = SimpleWeightedGraph(3) # or use `SimpleWeightedDiGraph` for directed graphs | ||
| add_edge!(g, 1, 2, 0.5) | ||
| add_edge!(g, 2, 3, 0.8) | ||
| add_edge!(g, 1, 3, 2.0) | ||
|
|
||
| # get weight of edge from vertex 1 to vertex 2 | ||
| get_weight(g, 1, 2) | ||
|
|
||
| # find the shortest path from vertex 1 to vertex 3 taking weights into account. | ||
| enumerate_paths(dijkstra_shortest_paths(g, 1), 3) | ||
| 3-element Array{Int64,1}: | ||
| 1 | ||
| 2 | ||
| 3 | ||
|
|
||
| # reweight the edge from 1 to 2 | ||
| add_edge!(g, 1, 2, 1.6) | ||
|
|
||
| # rerun the shortest path calculation from 1 to 3 | ||
| enumerate_paths(dijkstra_shortest_paths(g, 1), 3) | ||
| 2-element Array{Int64,1}: | ||
| 1 | ||
| 3 | ||
|
|
||
| # it's possible to build the graph from arrays of sources, destinations and weights | ||
| sources = [1,2,1] | ||
| destinations = [2,3,3] | ||
| weights = [0.5, 0.8, 2.0] | ||
| g = SimpleWeightedGraph(sources, destinations, weights) | ||
|
|
||
| # the combine keyword handles repeated pairs (sum by default) | ||
| g = SimpleWeightedGraph([1,2,1], [2,1,2], [1,1,1]; combine = +) | ||
| g.weights[2,1] == g.weights[1,2] == 3 # true | ||
|
|
||
| # WARNING: unexpected results might occur with non-associative combine functions | ||
|
|
||
| # notice that weights are indexed by [destination, source] | ||
| s = SimpleWeightedDiGraph([1,2,1], [2,1,2], [1,1,1]; combine = +) | ||
| s.weights[1,2] == 1 # true | ||
| s.weights[2,1] == 2 # true | ||
| ``` | ||
|
|
||
| Please pay attention to the fact that zero-weight edges are discarded by `add_edge!`. | ||
| This is due to the way the graph is stored (a sparse matrix). [A possible workaround | ||
| 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). | ||
|
|
||
| Note that adding or removing vertices or edges from these graph types is not particularly performant; | ||
| see [MetaGraphs.jl](https://github.com/JuliaGraphs/MetaGraphs.jl) for possible alternatives. | ||
| See the [documentation](https://JuliaGraphs.github.io/SimpleWeightedGraphs.jl/dev/) for a tutorial. |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.