Cannot add edge with Num type weights (from Symbolics)

Open
#49 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
julia
Domain
data

Research direction

Start at the add_edge! path shown in the MWE and inspect the zero-weight check that rejects Symbolics.jl Num values. Reproduce the example with SimpleWeightedDiGraph{Int,Num}, then verify that adding the symbolic edge succeeds without breaking the existing numeric-weight behavior.

Written by the indexing model from the issue text.

Description

Hi, so I'm trying to use the package for a graph with terms from Symbolics.jl as the weights. I'm pretty sure everything should work just fine except when I try to add a new edge via add_edge! which checks if the weight is zero and which does not work for these terms. For a MWE:

using Symbolics, SimpleWeightedGraphs, Graphs
g = SimpleWeightedDiGraph{Int,Num}(2)
add_edge!(g, 1, 2, 2.0) # works
@variables x
add_edge!(g, 1, 2, x) # does not work

This also seems like it could very well apply to other types, the problem here is the == operator does not do the same thing for Num. A simple fix may be to add this check in a try block and maybe print a warning that the check could not be done? Though such a warning should be toggleable to avoid excessive printing.

Dominant language
Julia
Stars
41
Forks
9
Avg merge
1d 21h
Merged PRs (30d)
1

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from JuliaGraphs/SimpleWeightedGraphs.jl

All issues in JuliaGraphs/SimpleWeightedGraphs.jl

Similar issues

More Julia issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.