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

Which functions go where? #4

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

Which functions go where? #4

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

Comments

@gdalle
Copy link
Member

gdalle commented Jun 28, 2023

Splitting out GraphsBase.jl means deciding which functions

  1. Have to be overridden by users (the "interface")
  2. Rely on the interface while remaining reasonably basic (the "core")
  3. Rely on the interface and core while adding more sophisticated functionality (the "algorithms")

The interface and core will go in GraphsBase.jl, the algorithms will remain in Graphs.jl.

@gdalle gdalle added the question Further information is requested label Jun 28, 2023
@gdalle
Copy link
Member Author

gdalle commented Jun 28, 2023

First classification attempt based on

@etiennedeg please comment and correct so I can update it:

Function Interface Core Algorithms
src(e) x
dst(e) x
zero(g) x
vertices(g) x
nv(g) x
has_vertex(g, v) x
edges(g) x
ne(g) x
has_edge(g, e) x
edges(g, u, v) x
has_self_loops(g) x
num_self_loops(g) x
[in/out_]edges(g, v) x
[in/out_]neighbors(g, v) x
common_[in/out_]neighbors(g, v) x
[in/out_]degree(g, v) x
[in/out_]degree(g) x
[in/out_]Δ(g) x
[in/out_]δ(g) x
[in/out_]degree_histogram(g) x
[in/out_]density(g) x
[in/out_]adjacency_matrix(g) x
add/rm_vertex!(g) x
add/rm_vertices!(g) x
add/rm_edge!(g) x
add/rm_edges!(g) x
weight(e) x
weights(g) x
set_weight!(g, e) x
squash(g) x
noallocextreme(f, comp, init, g) x
reverse(g) x
induced_subgraph(g) x
intersect(g, h) x
join(g, h) x
union(g, h) x
cartesian_product(g, h) x

Note that core functions can still be overridden for performance.

The list above also makes renaming propositions to homogeneize the style.

@etiennedeg
Copy link
Member

I have some doubts on the following functions:

  • squash : would it be defined only for integer graphs? Maybe algorithm...
  • reverse(g) (and probably reverse(e) also): I don't know how well this is defined. If we want to reverse an edge with metadata, I suppose we want to keep it, however, this is not always possible. For example, we define a directed graph with two types of edges, structural edges, and edges corresponding to the transitive closure of the graph, with as metadata a path between these two vertices. If we reverse the edge, the metadata is no longer a valid path between its extremities.
    However we can totally have a wrapper than allows to navigate the graph in reverse direction.
  • induced_subgraph: algorithm maybe?

@gdalle
Copy link
Member Author

gdalle commented Jun 29, 2023

squash : would it be defined only for integer graphs? Maybe algorithm...

Honestly we could also get rid of it. Maybe I'll open an issue on deprecations

reverse(g) (and probably reverse(e) also): I don't know how well this is defined.

If we have reverse(e) we can define reverse(g), so maybe reverse(e) should be part of the interface?

induced_subgraph: algorithm maybe?

I don't know, no strong opinion on my end.

@etiennedeg
Copy link
Member

My point is that reverse(e) is already ill-defined for meta-edges, for the example I gave on my last message, I have no idea what reverse could return.

@gdalle
Copy link
Member Author

gdalle commented Jun 29, 2023

My point is that reverse(e) is already ill-defined for meta-edges, for the example I gave on my last message, I have no idea what reverse could return.

Indeed so that is something we should ask users to implement

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

2 participants