Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Error: Non symmetric matrices created by repeated pairs #56

Open
mathieuLacroix opened this issue Nov 21, 2019 · 2 comments
Open

Error: Non symmetric matrices created by repeated pairs #56

mathieuLacroix opened this issue Nov 21, 2019 · 2 comments
Labels
doc documentation

Comments

@mathieuLacroix
Copy link

Hi,

Creating a simpleWeigthedGraph with repeated pairs may raise the error "Adjacency / distance matrices must be symmetric" due to numerical imprecision, even when using + as combine function.

For instance, the sparse matrix constructed when creating the weighted graph using the following data is not symmetric.

sources = [3, 3, 3, 3, 4, 1, 3, 3, 3, 4, 1, 3, 4]
destinations = [2, 4, 1, 1, 1, 4, 4, 2, 4, 2, 2, 1, 3]
weights = [0.22279, 0.287542, 0.461288, 0.222349, 0.838298, 0.295453, 0.995701, 0.878216, 0.0935724, 0.184148, 0.397035, 0.601133, 0.873484]
s = sparse(vcat(sources,destinations), vcat(destinations,sources), vcat(weights,weights),4, 4, +)
println(issymmetric(s))

Hence, g = SimpleWeightedGraph(sources, destinations, weights) raises an error.

Is it possible to find another way to construct the sparse matrix? Or indicate in the doc that repeated pairs should not be used with float weights?

Best,

@sbromberger
Copy link
Owner

you shouldn't be repeating (s,d) pairs in any constructor. That's definitely good cause for undefined behavior.

@matbesancon
Copy link
Contributor

Or indicate in the doc that repeated pairs should not be used with float weights?

Yes we should do that, add a warning for UBehavior in the docs

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
doc documentation
Projects
None yet
Development

No branches or pull requests

3 participants