Skip to content

Commit

Permalink
Add details to the docs fixing #8 and #9 (#42)
Browse files Browse the repository at this point in the history
fix #8 and #9 by
- specifying that self-loops are not supported
- specifying that constructors from edge lists should avoid duplicate
edges
  • Loading branch information
gdalle authored Apr 6, 2023
1 parent d995ffd commit 289d729
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Because `SimpleWeighted(Di)Graph`s are stored in sparse matrices, they have two

- Zero-weight edges are discarded by `add_edge!`. 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).

In additions, self-loops are not supported.

## Alternatives

If your graphs have more than just edge weights to store, take a look at [MetaGraphsNext.jl](https://github.com/JuliaGraphs/MetaGraphsNext.jl) or [MetaGraphs.jl](https://github.com/JuliaGraphs/MetaGraphs.jl) for more complex formats.
2 changes: 1 addition & 1 deletion src/SimpleWeightedGraphs.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
SimpleWeightedGraphs
A package for graphs with edge weights, stored as sparse adjacency matrices.
A package for graphs with edge weights and no self-loops, stored as sparse adjacency matrices.
"""
module SimpleWeightedGraphs

Expand Down
1 change: 1 addition & 0 deletions src/simpleweighteddigraph.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ SimpleWeightedDiGraph(adjmx; permute) # from adjacency matrix, possibly transpo
SimpleWeightedDiGraph(sources, destinations, weights) # from list of edges
```
Use `methods(SimpleWeightedDiGraph)` for the full list of constructors.
When building a new graph from a list of edges, be aware that repeating `(src, dst)` pairs may lead to undefined behavior (e.g. due to floating point errors during weight addition).
"""
mutable struct SimpleWeightedDiGraph{T<:Integer,U<:Real} <: AbstractSimpleWeightedGraph{T,U}
weights::SparseMatrixCSC{U,T}
Expand Down
1 change: 1 addition & 0 deletions src/simpleweightedgraph.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ SimpleWeightedGraph(adjmx) # from adjacency matrix
SimpleWeightedGraph(sources, destinations, weights) # from list of edges
```
Use `methods(SimpleWeightedGraph)` for the full list of constructors.
When building a new graph from a list of edges, be aware that repeating `(src, dst)` pairs may lead to undefined behavior (e.g. due to floating point errors during weight addition).
"""
mutable struct SimpleWeightedGraph{T<:Integer,U<:Real} <: AbstractSimpleWeightedGraph{T,U}
weights::SparseMatrixCSC{U,T}
Expand Down

0 comments on commit 289d729

Please sign in to comment.