Giter Club home page Giter Club logo

Comments (8)

stchang avatar stchang commented on July 21, 2024

Yes this is a good idea.

We might need to think about a few corner cases though. Like what should happen if someone calls add-edge after add-directed-edge`?

from graph.

a11ce avatar a11ce commented on July 21, 2024

Currently, add-edge! behaves like add-edges-in-both-directions! when used on a directed graph, right?

I think ideally it would instead only add one edge (or error?), but that would be a breaking change. The best way to follow the current behavior would be to have add-edge! ignore the flag.

I'm honestly having trouble thinking of use cases which require a graph to be changed from undirected to directed or vice versa. (In my case, the user gives a graph to my library but I don't need to modify it.)

from graph.

stchang avatar stchang commented on July 21, 2024

Actually, I forgot that the internal struct is not exported, only constructors that already distinguish directed/undirected (eg, mk-unweighted-graph/undirected and mk-unweighted-graph/directed) so this should be easy to add without breaking.

Maybe create two substructs (one for directed one for undirected) that have the existing struct as a super struct?

from graph.

a11ce avatar a11ce commented on July 21, 2024

If they are different substructs, what happens when you call add-directed-edge! on an undirected graph? Does it create and copy its data to a new directed graph?

Also, having 4 total substructs (weighted/unweighted, directed/undirected) might be messy.

from graph.

stchang avatar stchang commented on July 21, 2024

what happens when you call add-directed-edge! on an undirected graph

I think the right thing to do is to to error. But that might make things even more complicated since I think we would have to split the methods to the two structs as well. I think that's the cleaner design though. 4 structs might be slightly more verbose but they represent 4 distinct variations so it makes sense. I agree it would be easier to add a directed? flag but I dont like flags in general.

What do you think?

from graph.

a11ce avatar a11ce commented on July 21, 2024

In that case, it might make sense to combine add-edge! and add-directed-edge! into just add-edge!.

from graph.

stchang avatar stchang commented on July 21, 2024

oh that's a good point. That's would definitely be a breaking change though. Let me think about it some more

from graph.

a11ce avatar a11ce commented on July 21, 2024

Also to think about, 4 structs would mean directed-graph? and weighted-graph? (etc.) would need to be defined explicitly instead of as structure predicates.

Would you be okay with a flag if it was immutable (such that calling add-directed-edge! on an undirected graph errors instead of switching the flag (or add-directed-edge! is removed entirely as above))?

from graph.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.