From 289d7293e9e452dc7de43cbd4e6b64c742f2674d Mon Sep 17 00:00:00 2001 From: Guillaume Dalle <22795598+gdalle@users.noreply.github.com> Date: Thu, 6 Apr 2023 12:45:49 +0200 Subject: [PATCH] Add details to the docs fixing #8 and #9 (#42) fix #8 and #9 by - specifying that self-loops are not supported - specifying that constructors from edge lists should avoid duplicate edges --- docs/src/index.md | 2 ++ src/SimpleWeightedGraphs.jl | 2 +- src/simpleweighteddigraph.jl | 1 + src/simpleweightedgraph.jl | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/src/index.md b/docs/src/index.md index 0712df6..8bc0249 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -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. diff --git a/src/SimpleWeightedGraphs.jl b/src/SimpleWeightedGraphs.jl index 3111485..d2eb1c9 100644 --- a/src/SimpleWeightedGraphs.jl +++ b/src/SimpleWeightedGraphs.jl @@ -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 diff --git a/src/simpleweighteddigraph.jl b/src/simpleweighteddigraph.jl index 2714f41..7c41c26 100644 --- a/src/simpleweighteddigraph.jl +++ b/src/simpleweighteddigraph.jl @@ -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} diff --git a/src/simpleweightedgraph.jl b/src/simpleweightedgraph.jl index 3d7d6ec..bfc990e 100644 --- a/src/simpleweightedgraph.jl +++ b/src/simpleweightedgraph.jl @@ -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}