Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Directed vs undirected edges #16

Open
gdalle opened this issue Sep 28, 2023 · 5 comments
Open

Directed vs undirected edges #16

gdalle opened this issue Sep 28, 2023 · 5 comments
Labels
question Further information is requested

Comments

@gdalle
Copy link
Member

gdalle commented Sep 28, 2023

The edge types in Graphs.jl are directed but used for undirected graphs too, in sometimes incoherent ways. Should there be an undirected edge acting like a set? And if so, should the syntax change, eg. other_endpoint(e,u)?

@gdalle gdalle added the question Further information is requested label Sep 28, 2023
@gdalle gdalle mentioned this issue Oct 3, 2023
@CameronBieganek
Copy link

CameronBieganek commented Oct 3, 2023

Yeah, I think it makes sense for directed and undirected edges to be separate. In my GraphInterface/GraphTypes proposal, I have the following:

# GraphInterface.jl
abstract type AbstractEdge end
abstract type AbstractUndirectedEdge <: AbstractEdge end
abstract type AbstractDirectedEdge <: AbstractEdge end

# GraphTypes.jl
struct Edge <: AbstractUndirectedEdge
    # ...
end

...And I have Edge implemented so that Edge(1, 2) == Edge(2, 1) (and they hash the same).

@CameronBieganek
Copy link

One question: Do we want to support mixed graphs that include both directed and undirected graphs? I think that would have a significant impact on the interface design.

@gdalle
Copy link
Member Author

gdalle commented Oct 3, 2023

I would love a design where undirected edges have the right to exist, and where we can turn src(e) / dst(e) into other_vertex(e, v) or neighbor(e, v).

As for mixed graphs, it's a good question. My feeling is that if we get the interface right for the edges, most things should... sorta just work out of the box? Like a Dijkstra algorithm would return a mixed vector of directed and undirected

@mofeing
Copy link

mofeing commented Oct 3, 2023

I like @CameronBieganek's decision on Edge(a,b) == Edge(b,a). If we also define Base.in such that DiEdge(a,b) in Edge(a,b) == DiEdge(b,a) in Edge(a,b) == true, that should solve most problems with mixed graphs.

Only thing I'm not sure about is the use of AbstractUndirectedEdge and AbstractDirectedEdge. What interface do they define? What are their assumptions? Specifically I'm thinking about the implications for hypergraphs #23 and open edges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants