Comments (8)
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.
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.
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.
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.
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.
In that case, it might make sense to combine add-edge!
and add-directed-edge!
into just add-edge!
.
from graph.
oh that's a good point. That's would definitely be a breaking change though. Let me think about it some more
from graph.
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)
- Racket 5 tests don't work HOT 3
- stop supporting Racket versions < 6 HOT 1
- Tests fail on Racket 7 HOT 1
- Please add the racket topic to this repo HOT 1
- Allow setting of graphviz attributes other than color HOT 1
- Implement multigraphs HOT 1
- Serialization HOT 3
- Bug in maximum bipartite matching? HOT 12
- document gen:queue and queue-lib
- edge-weight should allow default value
- invalid version number
- Functional interface? HOT 3
- graphviz: support arbitrary edge values HOT 3
- `undirected-graph` raises `apply` error HOT 4
- support for multigraphs HOT 5
- Typed Racket interface HOT 7
- racket 8 breaks tests
- Is it possible to use Graph Properties to generate better `.dot` files? HOT 7
- Inbound and outbound neighbors for directed graphs
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graph.